You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jackwener (via GitHub)" <gi...@apache.org> on 2023/09/13 17:33:34 UTC

[GitHub] [arrow-datafusion] jackwener commented on a diff in pull request #7544: [MINOR]: Unknown input statistics in FilterExec

jackwener commented on code in PR #7544:
URL: https://github.com/apache/arrow-datafusion/pull/7544#discussion_r1324851466


##########
datafusion/common/src/stats.rs:
##########
@@ -70,3 +72,29 @@ pub struct ColumnStatistics {
     /// Number of distinct values
     pub distinct_count: Option<usize>,
 }
+
+impl ColumnStatistics {
+    /// Returns the [`Vec<ColumnStatistics>`] corresponding to the given schema by assigning
+    /// infinite bounds to each column in the schema. This is useful when even the input statistics
+    /// are not known, as the current executor can shrink the bounds of some columns.
+    pub fn new_with_unbounded_columns(schema: SchemaRef) -> Vec<ColumnStatistics> {
+        let data_types = schema
+            .fields()
+            .iter()
+            .map(|field| field.data_type())
+            .collect::<Vec<_>>();
+
+        data_types
+            .into_iter()
+            .map(|data_type| {
+                let dt = ScalarValue::try_from(data_type.clone()).ok();
+                ColumnStatistics {
+                    null_count: None,
+                    max_value: dt.clone(),
+                    min_value: dt,

Review Comment:
   👍



##########
datafusion/common/src/stats.rs:
##########
@@ -70,3 +72,29 @@ pub struct ColumnStatistics {
     /// Number of distinct values
     pub distinct_count: Option<usize>,
 }
+
+impl ColumnStatistics {
+    /// Returns the [`Vec<ColumnStatistics>`] corresponding to the given schema by assigning
+    /// infinite bounds to each column in the schema. This is useful when even the input statistics
+    /// are not known, as the current executor can shrink the bounds of some columns.
+    pub fn new_with_unbounded_columns(schema: SchemaRef) -> Vec<ColumnStatistics> {
+        let data_types = schema
+            .fields()
+            .iter()
+            .map(|field| field.data_type())
+            .collect::<Vec<_>>();
+
+        data_types
+            .into_iter()
+            .map(|data_type| {
+                let dt = ScalarValue::try_from(data_type.clone()).ok();
+                ColumnStatistics {
+                    null_count: None,
+                    max_value: dt.clone(),
+                    min_value: dt,

Review Comment:
   👍



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org