-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: Range Partitioning FFI #23520
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
Open
saadtajwar
wants to merge
5
commits into
apache:main
Choose a base branch
from
saadtajwar:saadtajwar/range-partitioning-ffi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+192
−19
Open
feat: Range Partitioning FFI #23520
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0a3cad5
feat: range partitioning FFI
saadtajwar 89dd04e
added tests
saadtajwar e4e9611
Merge branch 'main' into saadtajwar/range-partitioning-ffi
saadtajwar 01fef6e
Merge branch 'main' into saadtajwar/range-partitioning-ffi
saadtajwar efa9ed5
Merge branch 'main' into saadtajwar/range-partitioning-ffi
timsaucer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ use std::sync::Arc; | |
|
|
||
| use arrow::datatypes::SchemaRef; | ||
| use datafusion_common::error::{DataFusionError, Result}; | ||
| use datafusion_physical_expr::EquivalenceProperties; | ||
| use datafusion_physical_expr::{EquivalenceProperties, Partitioning}; | ||
| use datafusion_physical_expr_common::sort_expr::PhysicalSortExpr; | ||
| use datafusion_physical_plan::PlanProperties; | ||
| use datafusion_physical_plan::execution_plan::{Boundedness, EmissionType}; | ||
|
|
@@ -172,6 +172,7 @@ impl TryFrom<FFI_PlanProperties> for PlanProperties { | |
| .unwrap_or_default(); | ||
|
|
||
| let partitioning = unsafe { (ffi_props.output_partitioning)(&ffi_props) }; | ||
| let partitioning = Partitioning::try_from(partitioning)?; | ||
|
|
||
| let eq_properties = if sort_exprs.is_empty() { | ||
| EquivalenceProperties::new(Arc::new(schema)) | ||
|
|
@@ -187,7 +188,7 @@ impl TryFrom<FFI_PlanProperties> for PlanProperties { | |
|
|
||
| Ok(PlanProperties::new( | ||
| eq_properties, | ||
| (&partitioning).into(), | ||
| partitioning, | ||
| emission_type, | ||
| boundedness, | ||
| )) | ||
|
|
@@ -282,6 +283,29 @@ mod tests { | |
| )) | ||
| } | ||
|
|
||
| fn create_range_test_props() -> Result<PlanProperties> { | ||
| use arrow::datatypes::{DataType, Field, Schema}; | ||
| use datafusion_common::{ScalarValue, SplitPoint}; | ||
| use datafusion_physical_expr::{LexOrdering, RangePartitioning}; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mega nit: I prfer to keep imports at the module level to keep tests clean @timsaucer do yo uhave any preference? |
||
| let schema = Arc::new(Schema::new(vec![Field::new("a", DataType::Int64, false)])); | ||
| let col = datafusion::physical_plan::expressions::col("a", &schema)?; | ||
| let ordering = LexOrdering::new([PhysicalSortExpr::new_default(col)]) | ||
| .expect("non-empty ordering"); | ||
| let split_points = vec![ | ||
| SplitPoint::new(vec![ScalarValue::Int64(Some(10))]), | ||
| SplitPoint::new(vec![ScalarValue::Int64(Some(20))]), | ||
| ]; | ||
| let range = RangePartitioning::try_new(ordering, split_points)?; | ||
|
|
||
| Ok(PlanProperties::new( | ||
| EquivalenceProperties::new(schema), | ||
| Partitioning::Range(range), | ||
| EmissionType::Incremental, | ||
| Boundedness::Bounded, | ||
| )) | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_round_trip_ffi_plan_properties() -> Result<()> { | ||
| let original_props = create_test_props()?; | ||
|
|
@@ -314,4 +338,22 @@ mod tests { | |
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_round_trip_ffi_plan_properties_range_partitioning() -> Result<()> { | ||
| let original_props = create_range_test_props()?; | ||
|
|
||
| let mut local_props_ptr = FFI_PlanProperties::from(&original_props); | ||
| local_props_ptr.library_marker_id = crate::mock_foreign_marker_id; | ||
|
|
||
| let foreign_props: PlanProperties = local_props_ptr.try_into()?; | ||
|
|
||
| assert_eq!( | ||
| format!("{:?}", foreign_props.output_partitioning()), | ||
| format!("{:?}", original_props.output_partitioning()) | ||
| ); | ||
| assert_eq!(format!("{foreign_props:?}"), format!("{original_props:?}")); | ||
|
|
||
| Ok(()) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could we use the helper function
range_partitioning()to reduce boiler plate in the tests here. Just changing the partitioning that is built in there to compound 🤔