Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write file-level statistics when writing ORC files with zero rows #14707

Merged

Conversation

vuule
Copy link
Contributor

@vuule vuule commented Jan 4, 2024

Description

Fixes #14675
Write file-level statistics even when stripe-level statistics don't exist (no stripes).
Written statistics are in line with Pandas - zero sum, no min/max.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@vuule vuule added bug Something isn't working cuIO cuIO issue non-breaking Non-breaking change labels Jan 4, 2024
@vuule vuule self-assigned this Jan 4, 2024
@github-actions github-actions bot added the libcudf Affects libcudf (C++/CUDA) code. label Jan 4, 2024
@vuule vuule marked this pull request as ready for review January 4, 2024 22:48
@vuule vuule requested a review from a team as a code owner January 4, 2024 22:48
cpp/src/io/functions.cpp Outdated Show resolved Hide resolved
/**
* @brief Skip writing the footer and close the writer.
*/
void skip_close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a better name for this function. I fear the name implies that it's the close() that's skipped.
skip_footer_write_on_close() is too long.

If we can't think of a succinct name, maybe we should keep skip_close().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg, my updated code for this function got lost between commits.

I think skip_close is a pretty accurate name, given that we raise the _closed flag in skip_close and close() returns immediately if that flag is raised.

I'll update the docs above, sorry for the confusion.

Copy link
Contributor

@mythrocks mythrocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ttnghia
Copy link
Contributor

ttnghia commented Jan 5, 2024

Thanks for working on this.
Here is the latest output, which seems to be correct now:

File Version: 0.12 with FUTURE by Unknown(5) 
Rows: 0
Compression: SNAPPY
Compression size: 262144
Calendar: Julian/Gregorian
Type: struct<id:bigint,p:bigint>

Stripe Statistics:

File Statistics:
  Column 0: count: 0 hasNull: false
  Column 1: count: 0 hasNull: false sum: 0
  Column 2: count: 0 hasNull: false sum: 0

Stripes:

File length: 94 bytes
Padding length: 0 bytes
Padding ratio: 0%

vuule and others added 3 commits January 5, 2024 10:28
Co-authored-by: MithunR <mythrocks@gmail.com>
cpp/src/io/functions.cpp Outdated Show resolved Hide resolved
cpp/tests/io/orc_test.cpp Outdated Show resolved Hide resolved
std::generate_n(
std::back_inserter(expected_column_names),
expected.num_columns(),
[starting_index = 0]() mutable { return "_col" + std::to_string(starting_index++); });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow mutable lambda is great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I was told it's a code smell (but this is test code)
I think in theory mutable lambda means we should use an STL algorithm instead

@vuule vuule requested a review from ttnghia January 5, 2024 22:25
@vuule
Copy link
Contributor Author

vuule commented Jan 8, 2024

/merge

@rapids-bot rapids-bot bot merged commit ba7550a into rapidsai:branch-24.02 Jan 8, 2024
67 checks passed
@vuule vuule deleted the bug-write_orc-empty-file-stats branch January 8, 2024 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cuIO cuIO issue libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[BUG] ORC writer does not correctly output statistics for empty data file
3 participants