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

fix: Fix arrow error when sorting on empty batch #271

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

viirya
Copy link
Member

@viirya viirya commented Apr 16, 2024

Which issue does this PR close?

Closes #270.

Rationale for this change

What changes are included in this PR?

How are these changes tested?

core/Cargo.toml Outdated
datafusion = { default-features = false, git = "https://github.com/viirya/arrow-datafusion.git", rev = "111a940", features = ["unicode_expressions"] }
datafusion-functions = { git = "https://github.com/viirya/arrow-datafusion.git", rev = "111a940" }
datafusion-physical-expr = { git = "https://github.com/viirya/arrow-datafusion.git", rev = "111a940", default-features = false, features = ["unicode_expressions"] }
datafusion-common = { git = "https://github.com/viirya/arrow-datafusion.git", rev = "83d5782" }
Copy link
Member Author

Choose a reason for hiding this comment

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

This points to the upstream fix: apache/datafusion#10094

@viirya
Copy link
Member Author

viirya commented Apr 16, 2024

cc @sunchao @andygrove

datafusion = { default-features = false, git = "https://github.com/viirya/arrow-datafusion.git", rev = "111a940", features = ["unicode_expressions"] }
datafusion-functions = { git = "https://github.com/viirya/arrow-datafusion.git", rev = "111a940" }
datafusion-physical-expr = { git = "https://github.com/viirya/arrow-datafusion.git", rev = "111a940", default-features = false, features = ["unicode_expressions"] }
datafusion-common = { git = "https://github.com/viirya/arrow-datafusion.git", rev = "57b3be4" }
Copy link
Member

Choose a reason for hiding this comment

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

hmm, should we wait until the DF PR is merged and use https://github.com/apache/arrow-datafusion.git instead of your personal fork?

Copy link
Member Author

@viirya viirya Apr 16, 2024

Choose a reason for hiding this comment

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

It is pointed to my fork of DataFusion not just for this PR. We uses the fork of arrow-rs to use a workaround for the Java Arrow bug. So we must use the fork too in our DataFusion crate, otherwise rust compiler will complain duplicated structs etc.

Copy link
Member

Choose a reason for hiding this comment

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

I see. I missed #239. It is OK as long as we don't stay in this state for too long 😂

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, we will change back to official arrow-rs and DataFusion once we get new Java Arrow release.

@viirya
Copy link
Member Author

viirya commented Apr 16, 2024

I will hold this until the DataFusion patch is merged. Thanks.

RecordBatch::try_new(self.schema.clone(), vectors).map_err(|e| arrow_datafusion_err!(e))

let options = RecordBatchOptions::new().with_row_count(Some(batch.num_rows()));
RecordBatch::try_new_with_options(self.schema.clone(), vectors, &options)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should also check is there any other invocation of RecordBatch::try_new in the codebase and replace it with RecordBatch::try_new_with_options if necessary.

I just did a code search, maybe we probably need to revise the code in Expand.rs too: https://github.com/apache/arrow-datafusion-comet/blob/main/core/src/execution/datafusion/operators/expand.rs#L172

Of course, it should be done in a follow up PR.

Copy link
Member Author

@viirya viirya Apr 16, 2024

Choose a reason for hiding this comment

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

Good catch. Although I'm not sure if it is possible to have Expand with empty projections, it is good to have it here too. I will add it in this PR as it is a simple change.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 33.46%. Comparing base (9ab6c75) to head (36b5c3d).
Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #271      +/-   ##
============================================
- Coverage     33.47%   33.46%   -0.01%     
  Complexity      795      795              
============================================
  Files           110      110              
  Lines         37533    37533              
  Branches       8215     8215              
============================================
- Hits          12563    12562       -1     
- Misses        22322    22323       +1     
  Partials       2648     2648              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@viirya viirya merged commit 1aec2c9 into apache:main Apr 16, 2024
28 checks passed
@viirya
Copy link
Member Author

viirya commented Apr 16, 2024

Merged. Thanks.

@viirya viirya deleted the fix_empty_sort branch April 16, 2024 18:38
himadripal pushed a commit to himadripal/datafusion-comet that referenced this pull request Sep 7, 2024
* fix: Fix arrow error when sorting on empty batch

* Add RecordBatchOptions for Expand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Got arrow error when sorting on empty batch
5 participants