MCPcopy Create free account
hub / github.com/apache/datafusion / parquet_statistics

Function parquet_statistics

datafusion/core/tests/sql/path_partition.rs:434–510  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

432
433#[tokio::test]
434async fn parquet_statistics() -> Result<()> {
435 let mut config = SessionConfig::new();
436 config.options_mut().execution.collect_statistics = true;
437 let ctx = SessionContext::new_with_config(config);
438
439 register_partitioned_alltypes_parquet(
440 &ctx,
441 &[
442 "year=2021/month=09/day=09/file.parquet",
443 "year=2021/month=10/day=09/file.parquet",
444 "year=2021/month=10/day=28/file.parquet",
445 ],
446 &[
447 ("year", DataType::Int32),
448 ("month", DataType::Utf8),
449 ("day", DataType::Utf8),
450 ],
451 "mirror:///",
452 // This is the only file we found in the test set with
453 // actual stats. It has 1 column / 1 row.
454 "single_nan.parquet",
455 )
456 .await;
457
458 //// NO PROJECTION ////
459 let dataframe = ctx.sql("SELECT * FROM t").await?;
460 let physical_plan = dataframe.create_physical_plan().await?;
461 let schema = physical_plan.schema();
462 assert_eq!(schema.fields().len(), 4);
463
464 let stat_cols = physical_plan
465 .partition_statistics(None)?
466 .column_statistics
467 .clone();
468 assert_eq!(stat_cols.len(), 4);
469 // stats for the first col are read from the parquet file
470 assert_eq!(stat_cols[0].null_count, Precision::Exact(3));
471 // Partition column statistics (year=2021 for all 3 rows)
472 assert_eq!(stat_cols[1].null_count, Precision::Exact(0));
473 assert_eq!(
474 stat_cols[1].min_value,
475 Precision::Exact(ScalarValue::Int32(Some(2021)))
476 );
477 assert_eq!(
478 stat_cols[1].max_value,
479 Precision::Exact(ScalarValue::Int32(Some(2021)))
480 );
481 // month and day are Utf8 partition columns with statistics
482 assert_eq!(stat_cols[2].null_count, Precision::Exact(0));
483 assert_eq!(stat_cols[3].null_count, Precision::Exact(0));
484
485 //// WITH PROJECTION ////
486 let dataframe = ctx.sql("SELECT mycol, day FROM t WHERE day='28'").await?;
487 let physical_plan = dataframe.create_physical_plan().await?;
488 let schema = physical_plan.schema();
489 assert_eq!(schema.fields().len(), 2);
490
491 let stat_cols = physical_plan

Callers

nothing calls this directly

Calls 8

newFunction · 0.85
options_mutMethod · 0.80
sqlMethod · 0.80
create_physical_planMethod · 0.45
schemaMethod · 0.45
cloneMethod · 0.45
partition_statisticsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…