Skip to content

Commit c1b42f2

Browse files
committed
parquet filter pushdown correctness tests
1 parent 41467ab commit c1b42f2

File tree

6 files changed

+520
-14
lines changed

6 files changed

+520
-14
lines changed

datafusion/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ csv = "1.1.6"
108108
ctor = "0.1.22"
109109
doc-comment = "0.3"
110110
env_logger = "0.9"
111+
parquet-test-utils = { path = "../../parquet-test-utils" }
111112
rstest = "0.15.0"
112113
test-utils = { path = "../../test-utils" }
113114

datafusion/core/src/physical_plan/file_format/parquet.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,6 @@ mod tests {
11981198
use crate::datasource::listing::{FileRange, PartitionedFile};
11991199
use crate::datasource::object_store::ObjectStoreUrl;
12001200
use crate::execution::options::CsvReadOptions;
1201-
use crate::physical_plan::metrics::MetricValue;
12021201
use crate::prelude::{ParquetReadOptions, SessionConfig, SessionContext};
12031202
use crate::test::object_store::local_unpartitioned_file;
12041203
use crate::{
@@ -2029,15 +2028,8 @@ mod tests {
20292028
///
20302029
/// Panics if no such metric.
20312030
fn get_value(metrics: &MetricsSet, metric_name: &str) -> usize {
2032-
let sum = metrics.sum(|m| match m.value() {
2033-
MetricValue::Count { name, .. } if name == metric_name => true,
2034-
MetricValue::Time { name, .. } if name == metric_name => true,
2035-
_ => false,
2036-
});
2037-
2038-
match sum {
2039-
Some(MetricValue::Count { count, .. }) => count.value(),
2040-
Some(MetricValue::Time { time, .. }) => time.value(),
2031+
match metrics.sum_by_name(metric_name) {
2032+
Some(v) => v.as_usize(),
20412033
_ => {
20422034
panic!(
20432035
"Expected metric not found. Looking for '{}' in\n\n{:#?}",

datafusion/core/src/physical_plan/metrics/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,23 @@ impl MetricsSet {
241241
Some(accum)
242242
}
243243

244+
/// returns the sum of all the metrics with the specified name
245+
/// the returned set.
246+
pub fn sum_by_name(&self, metric_name: &str) -> Option<MetricValue> {
247+
self.sum(|m| match m.value() {
248+
MetricValue::Count { name, .. } => name == metric_name,
249+
MetricValue::Time { name, .. } => name == metric_name,
250+
MetricValue::OutputRows(_) => false,
251+
MetricValue::ElapsedCompute(_) => false,
252+
MetricValue::SpillCount(_) => false,
253+
MetricValue::SpilledBytes(_) => false,
254+
MetricValue::CurrentMemoryUsage(_) => false,
255+
MetricValue::Gauge { name, .. } => name == metric_name,
256+
MetricValue::StartTimestamp(_) => false,
257+
MetricValue::EndTimestamp(_) => false,
258+
})
259+
}
260+
244261
/// Returns returns a new derived `MetricsSet` where all metrics
245262
/// that had the same name and partition=`Some(..)` have been
246263
/// aggregated together. The resulting `MetricsSet` has all

0 commit comments

Comments
 (0)