Skip to content

Commit 1753037

Browse files
committed
Adjust tests as per comments
1 parent 67ccabe commit 1753037

2 files changed

Lines changed: 34 additions & 10 deletions

File tree

datafusion/core/tests/parquet/row_group_pruning.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ async fn prune_disabled() {
399399
// https://github.com/apache/datafusion/issues/9779 bug so that tests pass
400400
// if and only if Bloom filters on Int8 and Int16 columns are still buggy.
401401
macro_rules! int_tests {
402-
($bits:expr, $fn_lt:ident, $fn_eq:ident, $fn_scalar_fun_and_eq:ident, $fn_scalar_fun:ident, $fn_complex_expr:ident, $fn_complex_expr_subtract:ident, $fn_eq_in_list:ident, $fn_eq_in_list_2:ident, $fn_eq_in_list_negated:ident) => {
402+
($bits:expr, $fn_lt:ident, $fn_eq:ident, $fn_scalar_fun_and_eq:ident, $fn_scalar_fun:ident, $fn_complex_expr:ident, $fn_complex_expr_subtract:ident, $fn_eq_in_list:ident, $fn_eq_in_list_2:ident, $fn_eq_in_list_negated:ident, $fn_eq_any_literal_array:ident) => {
403403
#[tokio::test]
404404
async fn $fn_lt() {
405405
RowGroupPruningTest::new()
@@ -564,6 +564,25 @@ macro_rules! int_tests {
564564
.test_row_group_prune()
565565
.await;
566566
}
567+
568+
// Regression test for https://github.com/apache/datafusion/issues/22073:
569+
// `= ANY([literal])` must still allow Parquet file/row-group pruning,
570+
// the same way `IN (literal)` does.
571+
#[tokio::test]
572+
async fn $fn_eq_any_literal_array() {
573+
RowGroupPruningTest::new()
574+
.with_scenario(Scenario::Int)
575+
.with_query(&format!("SELECT * FROM t where i{} = ANY([100])", $bits))
576+
.with_expected_errors(Some(0))
577+
.with_matched_by_stats(Some(0))
578+
.with_pruned_by_stats(Some(0))
579+
.with_pruned_files(Some(1))
580+
.with_matched_by_bloom_filter(Some(0))
581+
.with_pruned_by_bloom_filter(Some(0))
582+
.with_expected_rows(0)
583+
.test_row_group_prune()
584+
.await;
585+
}
567586
};
568587
}
569588

@@ -578,7 +597,8 @@ int_tests!(
578597
prune_int32_complex_expr_subtract,
579598
prune_int32_eq_in_list,
580599
prune_int32_eq_in_list_2,
581-
prune_int32_eq_in_list_negated
600+
prune_int32_eq_in_list_negated,
601+
prune_int32_eq_any_literal_array
582602
);
583603
int_tests!(
584604
64,
@@ -590,7 +610,8 @@ int_tests!(
590610
prune_int64_complex_expr_subtract,
591611
prune_int64_eq_in_list,
592612
prune_int64_eq_in_list_2,
593-
prune_int64_eq_in_list_negated
613+
prune_int64_eq_in_list_negated,
614+
prune_int64_eq_any_literal_array
594615
);
595616

596617
// $bits: number of bits of the integer to test (8, 16, 32, 64)

datafusion/sqllogictest/test_files/array/array_all.slt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,12 @@ select NULL <> ALL(make_array(1, 2, 3));
136136
----
137137
NULL
138138

139-
# All-NULL arrays: returns NULL
139+
# All-NULL arrays with `=` or order operators: returns NULL
140140
query B
141141
select 5 = ALL(make_array(NULL::INT, NULL::INT));
142142
----
143143
NULL
144144

145-
query B
146-
select 5 <> ALL(make_array(NULL::INT, NULL::INT));
147-
----
148-
true
149-
150145
query B
151146
select 5 > ALL(make_array(NULL::INT, NULL::INT));
152147
----
@@ -167,7 +162,15 @@ select 5 <= ALL(make_array(NULL::INT, NULL::INT));
167162
----
168163
NULL
169164

170-
# Mixed NULL + non-NULL (non-NULL elements satisfy, but NULLs present → NULL)
165+
# All-NULL array with `<>` ALL: returns TRUE
166+
# (`<> ALL` desugars via `array_has`, which treats NULL elements as absent.)
167+
query B
168+
select 5 <> ALL(make_array(NULL::INT, NULL::INT));
169+
----
170+
true
171+
172+
# Mixed NULL + non-NULL where non-NULLs satisfy the condition: returns TRUE
173+
# (NULLs are ignored, mirroring `array_min`/`array_max`.)
171174
query B
172175
select 5 > ALL(make_array(3, NULL));
173176
----

0 commit comments

Comments
 (0)