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

Function prune_all_rows_null_counts

datafusion/pruning/src/pruning_predicate.rs:2476–2534  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2474
2475 #[test]
2476 fn prune_all_rows_null_counts() {
2477 // if null_count = row_count then we should prune the container for i = 0
2478 // regardless of the statistics
2479 let schema = Arc::new(Schema::new(vec![Field::new("i", DataType::Int32, true)]));
2480 let statistics = TestStatistics::new().with(
2481 "i",
2482 ContainerStats::new_i32(
2483 vec![Some(0)], // min
2484 vec![Some(0)], // max
2485 )
2486 .with_null_counts(vec![Some(1)])
2487 .with_row_counts(vec![Some(1)]),
2488 );
2489 let expected_ret = &[false];
2490 prune_with_expr(col("i").eq(lit(0)), &schema, &statistics, expected_ret);
2491
2492 // this should be true even if the container stats are missing
2493 let schema = Arc::new(Schema::new(vec![Field::new("i", DataType::Int32, true)]));
2494 let container_stats = ContainerStats {
2495 min: Some(Arc::new(Int32Array::from(vec![None]))),
2496 max: Some(Arc::new(Int32Array::from(vec![None]))),
2497 null_counts: Some(Arc::new(UInt64Array::from(vec![Some(1)]))),
2498 row_counts: Some(Arc::new(UInt64Array::from(vec![Some(1)]))),
2499 ..ContainerStats::default()
2500 };
2501 let statistics = TestStatistics::new().with("i", container_stats);
2502 let expected_ret = &[false];
2503 prune_with_expr(col("i").eq(lit(0)), &schema, &statistics, expected_ret);
2504
2505 // If the null counts themselves are missing we should be able to fall back to the stats
2506 let schema = Arc::new(Schema::new(vec![Field::new("i", DataType::Int32, true)]));
2507 let container_stats = ContainerStats {
2508 min: Some(Arc::new(Int32Array::from(vec![Some(0)]))),
2509 max: Some(Arc::new(Int32Array::from(vec![Some(0)]))),
2510 null_counts: Some(Arc::new(UInt64Array::from(vec![None]))),
2511 row_counts: Some(Arc::new(UInt64Array::from(vec![Some(1)]))),
2512 ..ContainerStats::default()
2513 };
2514 let statistics = TestStatistics::new().with("i", container_stats);
2515 let expected_ret = &[true];
2516 prune_with_expr(col("i").eq(lit(0)), &schema, &statistics, expected_ret);
2517 let expected_ret = &[false];
2518 prune_with_expr(col("i").gt(lit(0)), &schema, &statistics, expected_ret);
2519
2520 // Same for the row counts
2521 let schema = Arc::new(Schema::new(vec![Field::new("i", DataType::Int32, true)]));
2522 let container_stats = ContainerStats {
2523 min: Some(Arc::new(Int32Array::from(vec![Some(0)]))),
2524 max: Some(Arc::new(Int32Array::from(vec![Some(0)]))),
2525 null_counts: Some(Arc::new(UInt64Array::from(vec![Some(1)]))),
2526 row_counts: Some(Arc::new(UInt64Array::from(vec![None]))),
2527 ..ContainerStats::default()
2528 };
2529 let statistics = TestStatistics::new().with("i", container_stats);
2530 let expected_ret = &[true];
2531 prune_with_expr(col("i").eq(lit(0)), &schema, &statistics, expected_ret);
2532 let expected_ret = &[false];
2533 prune_with_expr(col("i").gt(lit(0)), &schema, &statistics, expected_ret);

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
prune_with_exprFunction · 0.85
with_row_countsMethod · 0.80
with_null_countsMethod · 0.80
colFunction · 0.50
litFunction · 0.50
withMethod · 0.45
eqMethod · 0.45
gtMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…