Skip to content

Commit d94ee10

Browse files
committed
Fix bugs.
1 parent a529efc commit d94ee10

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/query/storages/parquet/src/parquet_reader/meta.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ impl ParquetReader {
6565
let mut stats_of_row_groups = HashMap::with_capacity(rgs.len());
6666

6767
for index in indices {
68+
if rgs
69+
.iter()
70+
.any(|rg| rg.columns()[*index].metadata().statistics.is_none())
71+
{
72+
return Err(ErrorCode::InvalidArgument(
73+
"Some columns of the row groups have no statistics",
74+
));
75+
}
76+
6877
let field = &schema.fields[*index];
6978
let column_stats = pread::statistics::deserialize(field, rgs)?;
7079
stats_of_row_groups.insert(*index, BatchStatistics::from(column_stats));
@@ -97,8 +106,8 @@ pub struct BatchStatistics {
97106
impl BatchStatistics {
98107
pub fn get(&self, index: usize) -> ColumnStatistics {
99108
ColumnStatistics {
100-
min: self.min_values.get(0),
101-
max: self.max_values.get(0),
109+
min: self.min_values.get(index),
110+
max: self.max_values.get(index),
102111
null_count: self.null_count.get_u64(index).unwrap(),
103112
in_memory_size: 0, // this field is not used.
104113
distinct_of_values: self.distinct_count.get_u64(index).ok(),
@@ -111,7 +120,7 @@ impl From<pread::statistics::Statistics> for BatchStatistics {
111120
let null_count = UInt64Column::from_arrow_array(&*stats.null_count);
112121
let distinct_count = UInt64Column::from_arrow_array(&*stats.distinct_count);
113122
let min_values = stats.min_value.clone().into_column();
114-
let max_values = stats.min_value.clone().into_column();
123+
let max_values = stats.max_value.clone().into_column();
115124
Self {
116125
null_count,
117126
distinct_count,

src/query/storages/parquet/src/table_function/read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl ParquetTable {
139139

140140
// do parition at the begin of the whole pipeline.
141141
let push_downs = plan.push_downs.clone();
142-
let schema = plan.schema();
142+
let schema = plan.source_info.schema();
143143
pipeline.set_on_init(move || {
144144
let mut partitions = Vec::with_capacity(locations.len());
145145

src/query/storages/pruner/src/range_pruner.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ impl RangePruner for RangeFilter {
5555
}
5656
}
5757

58+
/// Create a new [`RangePruner`] from expression and schema.
59+
///
60+
/// Note: the schema should be the schema of the table, not the schema of the input.
5861
pub fn new_range_pruner<'a>(
5962
ctx: &Arc<dyn TableContext>,
6063
filter_expr: Option<&'a [Expression]>,

0 commit comments

Comments
 (0)