-
Notifications
You must be signed in to change notification settings - Fork 53
feat(datafusion): support fetch contract in PaimonTableScan #224
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
c0499e2
2c61d07
9ba6eae
1b625de
cd3af4c
c8e9e18
be3f8ec
2266127
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,22 @@ pub(crate) fn build_pushed_predicate(filters: &[Expr], fields: &[DataField]) -> | |
| } | ||
| } | ||
|
|
||
| /// Whether it is safe to pass a row-count hint down to paimon-core planning. | ||
| /// | ||
| /// This stays intentionally narrow: the hint is only safe when there are no | ||
| /// filters, or when every filter is exact at the table-provider boundary. | ||
| pub(crate) fn can_push_down_limit_hint( | ||
| filters: &[Expr], | ||
| fields: &[DataField], | ||
| partition_keys: &[String], | ||
| ) -> bool { | ||
| filters.is_empty() | ||
| || filters.iter().all(|filter| { | ||
| classify_filter_pushdown(filter, fields, partition_keys) | ||
|
||
| == TableProviderFilterPushDown::Exact | ||
| }) | ||
| } | ||
|
|
||
| fn split_conjunction(expr: &Expr) -> Vec<&Expr> { | ||
| match expr { | ||
| Expr::BinaryExpr(BinaryExpr { | ||
|
|
@@ -392,6 +408,54 @@ mod tests { | |
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_can_push_down_limit_hint_without_filters() { | ||
| let fields = test_fields(); | ||
|
|
||
| assert!(can_push_down_limit_hint(&[], &fields, &partition_keys())); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_can_push_down_limit_hint_for_exact_filters() { | ||
| let fields = test_fields(); | ||
| let filters = vec![ | ||
| Expr::Column(Column::from_name("dt")).eq(lit("2024-01-01")), | ||
| Expr::Column(Column::from_name("hr")).eq(lit(10)), | ||
| ]; | ||
|
|
||
| assert!(can_push_down_limit_hint( | ||
| &filters, | ||
| &fields, | ||
| &partition_keys() | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_can_push_down_limit_hint_rejects_inexact_filters() { | ||
| let fields = test_fields(); | ||
| let filters = vec![Expr::Column(Column::from_name("id")).gt(lit(10))]; | ||
|
|
||
| assert!(!can_push_down_limit_hint( | ||
| &filters, | ||
| &fields, | ||
| &partition_keys() | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_can_push_down_limit_hint_rejects_unsupported_filters() { | ||
| let fields = test_fields(); | ||
| let filters = vec![Expr::Not(Box::new( | ||
| Expr::Column(Column::from_name("dt")).eq(lit("2024-01-01")), | ||
| ))]; | ||
|
|
||
| assert!(!can_push_down_limit_hint( | ||
| &filters, | ||
| &fields, | ||
| &partition_keys() | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_translate_reversed_partition_comparison() { | ||
| let fields = test_fields(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,4 +17,4 @@ | |
|
|
||
| pub(crate) mod scan; | ||
|
|
||
| pub use scan::PaimonTableScan; | ||
| pub(crate) use scan::PaimonTableScan; | ||
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.
I think table_scan has already made this judgment.