mkleen commented on code in PR #23201:
URL: https://github.com/apache/datafusion/pull/23201#discussion_r3480501810


##########
datafusion/execution/src/cache/mod.rs:
##########
@@ -165,3 +166,124 @@ impl Display for TableScopedPath {
         }
     }
 }
+
+/// A fingerprint of the `file_schema` used to compute a file's statistics.
+///
+/// Captures exactly the attributes that determine the layout and meaning of
+/// `Statistics::column_statistics`: each column's name, data type and
+/// nullability, in order. It deliberately excludes field/schema metadata, 
which
+/// cannot affect statistics — including it would needlessly fragment the 
cache.
+#[derive(PartialEq, Eq, Hash, Clone, Debug)]
+pub struct SchemaFingerprint(Vec<(String, DataType, bool)>);
+
+impl SchemaFingerprint {
+    /// Builds a fingerprint from the `file_schema` used to compute statistics
+    /// (the schema of the columns physically read, not the full table schema —
+    /// partition columns and their statistics are handled separately).
+    pub fn from_schema(file_schema: &Schema) -> Self {
+        Self(
+            file_schema
+                .fields()
+                .iter()
+                .map(|f| (f.name().clone(), f.data_type().clone(), 
f.is_nullable()))
+                .collect(),
+        )
+    }
+}
+
+impl DFHeapSize for SchemaFingerprint {

Review Comment:
   If you add a `DFHeapSize` Trait for a 3 Value Tuple in `heap_size.rs` such 
as: 
   ```rust
   impl<A, B, C> DFHeapSize for (A, B, C)
   where
       A: DFHeapSize,
       B: DFHeapSize,
       C: DFHeapSize,
   {
       fn heap_size(&self, ctx: &mut DFHeapSizeCtx) -> usize {
           self.0.heap_size(ctx) + self.1.heap_size(ctx) + self.2.heap_size(ctx)
       }
   }
   ```
   
   This becomes: 
   
   ```rust
   impl DFHeapSize for SchemaFingerprint {
       fn heap_size(&self, ctx: &mut DFHeapSizeCtx) -> usize {
         self.0.heap_size(ctx)
       }
   }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to