Rewrites column_expr so that all appearances of column are replaced with a reference to either the min or max statistics column, while keeping track that a reference to the statistics column is required for example, an expression like `col("foo") > 5`, when called with Max would result in an expression like `col("foo_max") > 5` with the appropriate entry noted in self.columns
(
&mut self,
column: &phys_expr::Column,
column_expr: &Arc<dyn PhysicalExpr>,
field: &Field,
stat_type: StatisticsType,
)
| 806 | /// with Max would result in an expression like `col("foo_max") > |
| 807 | /// 5` with the appropriate entry noted in self.columns |
| 808 | fn stat_column_expr( |
| 809 | &mut self, |
| 810 | column: &phys_expr::Column, |
| 811 | column_expr: &Arc<dyn PhysicalExpr>, |
| 812 | field: &Field, |
| 813 | stat_type: StatisticsType, |
| 814 | ) -> Result<Arc<dyn PhysicalExpr>> { |
| 815 | let (idx, need_to_insert) = match self.find_stat_column(column, stat_type) { |
| 816 | Some(idx) => (idx, false), |
| 817 | None => (self.columns.len(), true), |
| 818 | }; |
| 819 | |
| 820 | let column_name = column.name(); |
| 821 | let stat_column_name = match stat_type { |
| 822 | StatisticsType::Min => format!("{column_name}_min"), |
| 823 | StatisticsType::Max => format!("{column_name}_max"), |
| 824 | StatisticsType::NullCount => format!("{column_name}_null_count"), |
| 825 | StatisticsType::RowCount => "row_count".to_string(), |
| 826 | }; |
| 827 | |
| 828 | let stat_column = phys_expr::Column::new(&stat_column_name, idx); |
| 829 | |
| 830 | // only add statistics column if not previously added |
| 831 | if need_to_insert { |
| 832 | // may be null if statistics are not present |
| 833 | let nullable = true; |
| 834 | let stat_field = |
| 835 | Field::new(stat_column.name(), field.data_type().clone(), nullable); |
| 836 | self.columns.push((column.clone(), stat_type, stat_field)); |
| 837 | } |
| 838 | rewrite_column_expr(Arc::clone(column_expr), column, &stat_column) |
| 839 | } |
| 840 | |
| 841 | /// rewrite col --> col_min |
| 842 | fn min_column_expr( |
no test coverage detected