-
Notifications
You must be signed in to change notification settings - Fork 212
feat!: expose read-side expected stats schemas #3308
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 1 commit
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 |
|---|---|---|
|
|
@@ -30,7 +30,9 @@ use crate::metrics::{ | |
| use crate::path::ParsedLogPath; | ||
| use crate::scan::ScanBuilder; | ||
| use crate::schema::SchemaRef; | ||
| use crate::table_configuration::{InCommitTimestampEnablement, TableConfiguration}; | ||
| use crate::table_configuration::{ | ||
| ExpectedStatsSchemas, InCommitTimestampEnablement, TableConfiguration, | ||
| }; | ||
| use crate::table_features::{physical_to_logical_column_name_and_type, TableFeature}; | ||
| use crate::table_properties::TableProperties; | ||
| use crate::transaction::builder::alter_table::AlterTableTransactionBuilder; | ||
|
|
@@ -343,6 +345,34 @@ impl Snapshot { | |
| self.table_configuration.logical_schema() | ||
| } | ||
|
|
||
| /// Returns the expected logical and physical schemas for file statistics. | ||
| /// | ||
| /// `extra_indexed_columns` are logical column paths that may have statistics even when they | ||
| /// fall outside the table's configured indexed-column set. Resolvable extra columns are | ||
| /// included in both returned schemas; partition columns and unresolvable paths are omitted. | ||
| /// The physical schema applies the table's column-mapping mode. | ||
| /// | ||
| /// Both schemas contain `numRecords` and `tightBounds`. When at least one data column is | ||
| /// selected, they also contain `nullCount` and, for eligible data types, `minValues` and | ||
| /// `maxValues`. Nested fields mirror the selected portion of the table schema. | ||
| /// | ||
| /// Pass the same extra columns to [`StatsOptions::all_struct_with_extra_indexed`] when building | ||
| /// a scan that returns structured statistics. | ||
| /// | ||
| /// # Errors | ||
|
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. Nit4 The # Errors section only restates the return type, and the doc does not mention that both returned schemas are metadata-stripped even though the logical field is described as connector-facing. Raised by: maintainer-claude-reviewer. Suggested fix: name the concrete error condition (or drop the section) and note that both schemas have field metadata stripped. |
||
| /// | ||
| /// Returns an error if kernel cannot construct a valid stats schema. | ||
| /// | ||
| /// [`StatsOptions::all_struct_with_extra_indexed`]: | ||
| /// crate::scan::StatsOptions::all_struct_with_extra_indexed | ||
| pub fn expected_stats_schemas( | ||
|
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. Nit6 expected_stats_schemas(&[ColumnName]) models only the all_struct_with_extra_indexed policy; a connector scanning with struct_columns(...) gets a schema that can disagree with its own scan output, the mismatch this API aims to prevent. Raised by: architecture-reviewer. Suggested fix: consider accepting the scan's StatsOptions (or the StructStats policy) so one method covers all modes, or scope the method name to the single policy it serves. |
||
| &self, | ||
| extra_indexed_columns: &[ColumnName], | ||
| ) -> DeltaResult<ExpectedStatsSchemas> { | ||
| self.table_configuration | ||
| .build_expected_stats_schemas(extra_indexed_columns) | ||
| } | ||
|
|
||
| /// Estimated owned heap size in bytes for this snapshot. Best-effort estimate | ||
| /// for capacity tracking, not authoritative. | ||
| /// | ||
|
|
||
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.
Nit2 The consistency test covers only a flat two-column schema, asserts the physical minValues field count but not the logical side, and does not exercise partition-column exclusion through the new API's logical branch or a nested/dataSkippingStatsColumns schema. Raised by: test-coverage-reviewer, delta-protocol-reviewer, maintainer-codex-reviewer. Suggested fix: add assert_eq!(logical_min_values.num_fields(), 2); and a partitioned-table case asserting the partition column is absent from both logical and physical.