You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "QuakeWang (via GitHub)" <gi...@apache.org> on 2026/04/03 01:58:28 UTC
[PR] feat(scan): support data-level stats pruning in TableScan [paimon-rust]
QuakeWang opened a new pull request, #196:
URL: https://github.com/apache/paimon-rust/pull/196
<!--
Thank you very much for contributing to Paimon Rust - we are happy that you want to help us improve it. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.
## Contribution Checklist
- Make sure that the pull request corresponds to a [GitHub issue](https://github.com/apache/paimon-rust/issues). Exceptions are made for typos in documentation or comments, which need no issue.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `cargo test` passes.
- Each pull request should address only one issue, not mix up code from multiple issues.
**(The sections below can be removed for hotfixes or typos)**
-->
### Purpose
<!-- Linking this pull request to the issue -->
Linked issue: close #188
<!-- What is the purpose of the change -->
### Brief change log
<!-- Please describe the changes made in this pull request and explain how they address the issue -->
### Tests
<!-- List unit tests or integration cases to verify this change -->
### API and Format
<!-- Does this change affect API or storage format -->
### Documentation
<!-- Does this change introduce a new feature or require documentation updates -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(scan): support data-level stats pruning in TableScan [paimon-rust]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #196:
URL: https://github.com/apache/paimon-rust/pull/196#discussion_r3031918379
##########
crates/paimon/src/table/table_scan.rs:
##########
@@ -166,6 +168,72 @@ fn partition_matches_predicate(
}
}
+#[derive(Debug, Clone)]
+struct FileStatsRows {
+ row_count: i64,
+ min_values: Option<BinaryRow>,
+ max_values: Option<BinaryRow>,
+ null_counts: Vec<i64>,
+}
+
+impl FileStatsRows {
+ fn from_data_file(file: &DataFileMeta) -> Self {
+ Self {
+ row_count: file.row_count,
+ min_values: BinaryRow::from_serialized_bytes(file.value_stats.min_values()).ok(),
+ max_values: BinaryRow::from_serialized_bytes(file.value_stats.max_values()).ok(),
+ null_counts: file.value_stats.null_counts().clone(),
+ }
+ }
+
+ fn null_count(&self, index: usize) -> Option<i64> {
+ self.null_counts.get(index).copied()
+ }
+
+ /// Check whether the stats rows have the expected number of fields.
+ ///
+ /// If either min or max BinaryRow has an arity different from
+ /// `expected_fields`, the stats were likely written in dense mode or
+ /// under a different schema — making index-based access unsafe.
+ fn arity_matches(&self, expected_fields: usize) -> bool {
Review Comment:
Maybe it is better to merge this first: https://github.com/apache/paimon-rust/pull/197
We can finish schema evolution here. Read schema file to check evolution here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(scan): support data-level stats pruning in TableScan [paimon-rust]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #196:
URL: https://github.com/apache/paimon-rust/pull/196
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(scan): support data-level stats pruning in TableScan [paimon-rust]
Posted by "QuakeWang (via GitHub)" <gi...@apache.org>.
QuakeWang commented on code in PR #196:
URL: https://github.com/apache/paimon-rust/pull/196#discussion_r3031931363
##########
crates/paimon/src/table/table_scan.rs:
##########
@@ -166,6 +168,72 @@ fn partition_matches_predicate(
}
}
+#[derive(Debug, Clone)]
+struct FileStatsRows {
+ row_count: i64,
+ min_values: Option<BinaryRow>,
+ max_values: Option<BinaryRow>,
+ null_counts: Vec<i64>,
+}
+
+impl FileStatsRows {
+ fn from_data_file(file: &DataFileMeta) -> Self {
+ Self {
+ row_count: file.row_count,
+ min_values: BinaryRow::from_serialized_bytes(file.value_stats.min_values()).ok(),
+ max_values: BinaryRow::from_serialized_bytes(file.value_stats.max_values()).ok(),
+ null_counts: file.value_stats.null_counts().clone(),
+ }
+ }
+
+ fn null_count(&self, index: usize) -> Option<i64> {
+ self.null_counts.get(index).copied()
+ }
+
+ /// Check whether the stats rows have the expected number of fields.
+ ///
+ /// If either min or max BinaryRow has an arity different from
+ /// `expected_fields`, the stats were likely written in dense mode or
+ /// under a different schema — making index-based access unsafe.
+ fn arity_matches(&self, expected_fields: usize) -> bool {
Review Comment:
> Maybe it is better to merge this first: #197
>
> We can finish schema evolution here. Read schema file to check evolution here.
Good idea, I will review #197 soon~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(scan): support data-level stats pruning in TableScan [paimon-rust]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #196:
URL: https://github.com/apache/paimon-rust/pull/196#discussion_r3031610096
##########
crates/paimon/src/table/table_scan.rs:
##########
@@ -166,6 +168,72 @@ fn partition_matches_predicate(
}
}
+#[derive(Debug, Clone)]
+struct FileStatsRows {
+ row_count: i64,
+ min_values: Option<BinaryRow>,
+ max_values: Option<BinaryRow>,
+ null_counts: Vec<i64>,
+}
+
+impl FileStatsRows {
+ fn from_data_file(file: &DataFileMeta) -> Self {
+ Self {
+ row_count: file.row_count,
+ min_values: BinaryRow::from_serialized_bytes(file.value_stats.min_values()).ok(),
+ max_values: BinaryRow::from_serialized_bytes(file.value_stats.max_values()).ok(),
+ null_counts: file.value_stats.null_counts().clone(),
+ }
+ }
+
+ fn null_count(&self, index: usize) -> Option<i64> {
+ self.null_counts.get(index).copied()
+ }
+
+ /// Check whether the stats rows have the expected number of fields.
+ ///
+ /// If either min or max BinaryRow has an arity different from
+ /// `expected_fields`, the stats were likely written in dense mode or
+ /// under a different schema — making index-based access unsafe.
+ fn arity_matches(&self, expected_fields: usize) -> bool {
Review Comment:
We should consider schema evolution here, otherwise may occur exception here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(scan): support data-level stats pruning in TableScan [paimon-rust]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #196:
URL: https://github.com/apache/paimon-rust/pull/196#discussion_r3034974184
##########
crates/integration_tests/tests/read_tables.rs:
##########
@@ -948,58 +1005,6 @@ async fn test_read_data_evolution_table_with_projection() {
);
}
-// ---------------------------------------------------------------------------
-// Limit pushdown integration tests
Review Comment:
I'll try to fix it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(scan): support data-level stats pruning in TableScan [paimon-rust]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #196:
URL: https://github.com/apache/paimon-rust/pull/196#discussion_r3031778175
##########
crates/paimon/src/table/table_scan.rs:
##########
@@ -166,6 +168,86 @@ fn partition_matches_predicate(
}
}
+#[derive(Debug, Clone)]
+struct FileStatsRows {
+ row_count: i64,
+ min_values: Option<BinaryRow>,
+ max_values: Option<BinaryRow>,
+ null_counts: Vec<i64>,
+}
+
+impl FileStatsRows {
+ /// Build file stats only when they are compatible with the current table schema.
+ ///
+ /// Schema-evolved files are conservatively skipped here so callers don't
+ /// accidentally interpret old stats rows using current field indexes.
+ fn try_from_data_file(
+ file: &DataFileMeta,
+ current_schema_id: i64,
+ expected_fields: usize,
+ ) -> Option<Self> {
+ if file.schema_id != current_schema_id {
+ return None;
+ }
+
+ let stats = Self {
+ row_count: file.row_count,
+ min_values: BinaryRow::from_serialized_bytes(file.value_stats.min_values()).ok(),
+ max_values: BinaryRow::from_serialized_bytes(file.value_stats.max_values()).ok(),
+ null_counts: file.value_stats.null_counts().clone(),
+ };
+
+ stats.arity_matches(expected_fields).then_some(stats)
+ }
+
+ fn null_count(&self, index: usize) -> Option<i64> {
+ self.null_counts.get(index).copied()
+ }
+
+ /// Check whether the stats rows have the expected number of fields.
+ ///
+ /// If either min or max BinaryRow has an arity different from
+ /// `expected_fields`, the stats were likely written in dense mode or
+ /// under a different schema — making index-based access unsafe.
+ fn arity_matches(&self, expected_fields: usize) -> bool {
+ let min_ok = self
+ .min_values
+ .as_ref()
+ .is_none_or(|r| r.arity() as usize == expected_fields);
+ let max_ok = self
+ .max_values
+ .as_ref()
+ .is_none_or(|r| r.arity() as usize == expected_fields);
+ let null_ok = self.null_counts.is_empty() || self.null_counts.len() == expected_fields;
+ min_ok && max_ok && null_ok
+ }
+}
+
+fn split_partition_and_data_predicates(
Review Comment:
Can you align this implementation to Java `splitPartitionPredicatesAndDataPredicates`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(scan): support data-level stats pruning in TableScan [paimon-rust]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #196:
URL: https://github.com/apache/paimon-rust/pull/196#discussion_r3034971141
##########
crates/integration_tests/tests/read_tables.rs:
##########
@@ -948,58 +1005,6 @@ async fn test_read_data_evolution_table_with_projection() {
);
}
-// ---------------------------------------------------------------------------
-// Limit pushdown integration tests
Review Comment:
Why remove limit tests?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(scan): support data-level stats pruning in TableScan [paimon-rust]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #196:
URL: https://github.com/apache/paimon-rust/pull/196#discussion_r3031778175
##########
crates/paimon/src/table/table_scan.rs:
##########
@@ -166,6 +168,86 @@ fn partition_matches_predicate(
}
}
+#[derive(Debug, Clone)]
+struct FileStatsRows {
+ row_count: i64,
+ min_values: Option<BinaryRow>,
+ max_values: Option<BinaryRow>,
+ null_counts: Vec<i64>,
+}
+
+impl FileStatsRows {
+ /// Build file stats only when they are compatible with the current table schema.
+ ///
+ /// Schema-evolved files are conservatively skipped here so callers don't
+ /// accidentally interpret old stats rows using current field indexes.
+ fn try_from_data_file(
+ file: &DataFileMeta,
+ current_schema_id: i64,
+ expected_fields: usize,
+ ) -> Option<Self> {
+ if file.schema_id != current_schema_id {
+ return None;
+ }
+
+ let stats = Self {
+ row_count: file.row_count,
+ min_values: BinaryRow::from_serialized_bytes(file.value_stats.min_values()).ok(),
+ max_values: BinaryRow::from_serialized_bytes(file.value_stats.max_values()).ok(),
+ null_counts: file.value_stats.null_counts().clone(),
+ };
+
+ stats.arity_matches(expected_fields).then_some(stats)
+ }
+
+ fn null_count(&self, index: usize) -> Option<i64> {
+ self.null_counts.get(index).copied()
+ }
+
+ /// Check whether the stats rows have the expected number of fields.
+ ///
+ /// If either min or max BinaryRow has an arity different from
+ /// `expected_fields`, the stats were likely written in dense mode or
+ /// under a different schema — making index-based access unsafe.
+ fn arity_matches(&self, expected_fields: usize) -> bool {
+ let min_ok = self
+ .min_values
+ .as_ref()
+ .is_none_or(|r| r.arity() as usize == expected_fields);
+ let max_ok = self
+ .max_values
+ .as_ref()
+ .is_none_or(|r| r.arity() as usize == expected_fields);
+ let null_ok = self.null_counts.is_empty() || self.null_counts.len() == expected_fields;
+ min_ok && max_ok && null_ok
+ }
+}
+
+fn split_partition_and_data_predicates(
Review Comment:
Can you align this implementation to Java `splitPartitionPredicatesAndDataPredicates`? https://github.com/apache/paimon/pull/7473 is important to many use cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org