Skip to content

Commit 772bca6

Browse files
committed
lint, apply #18832 (comment)
1 parent c6057dd commit 772bca6

File tree

1 file changed

+11
-14
lines changed
  • datafusion/physical-expr/src/expressions

1 file changed

+11
-14
lines changed

datafusion/physical-expr/src/expressions/in_list.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,10 @@ impl StaticFilter for Int32StaticFilter {
241241
.ok_or_else(|| exec_datafusion_err!("Failed to downcast array"))?;
242242

243243
let haystack_has_nulls = self.null_count > 0;
244+
let has_nulls = v.null_count() > 0 || haystack_has_nulls;
244245

245-
let result = match (v.null_count() > 0, haystack_has_nulls, negated) {
246-
(true, _, false) | (false, true, false) => {
246+
let result = match (has_nulls, negated) {
247+
(true, false) => {
247248
// Either needle or haystack has nulls, not negated
248249
BooleanArray::from_iter(v.iter().map(|value| match value {
249250
None => None,
@@ -258,7 +259,7 @@ impl StaticFilter for Int32StaticFilter {
258259
}
259260
}))
260261
}
261-
(true, _, true) | (false, true, true) => {
262+
(true, true) => {
262263
// Either needle or haystack has nulls, negated
263264
BooleanArray::from_iter(v.iter().map(|value| match value {
264265
None => None,
@@ -273,13 +274,13 @@ impl StaticFilter for Int32StaticFilter {
273274
}
274275
}))
275276
}
276-
(false, false, false) => {
277+
(false, false) => {
277278
// No nulls anywhere, not negated
278279
BooleanArray::from_iter(
279280
v.values().iter().map(|value| self.values.contains(value)),
280281
)
281282
}
282-
(false, false, true) => {
283+
(false, true) => {
283284
// No nulls anywhere, negated
284285
BooleanArray::from_iter(
285286
v.values().iter().map(|value| !self.values.contains(value)),
@@ -820,7 +821,7 @@ mod tests {
820821

821822
let col_a = col("a", &schema)?;
822823
let batch =
823-
RecordBatch::try_new(Arc::new(schema.clone()), vec![array.clone()])?;
824+
RecordBatch::try_new(Arc::new(schema.clone()), vec![Arc::clone(&array)])?;
824825

825826
// Helper to format SQL-like representation for error messages
826827
let _format_sql = |negated: bool, with_null: bool| -> String {
@@ -2815,24 +2816,21 @@ mod tests {
28152816
let test_name = utf8_case.name;
28162817
run_dictionary_in_list_test(utf8_case).map_err(|e| {
28172818
datafusion_common::DataFusionError::Execution(format!(
2818-
"Dictionary test '{}' failed: {}",
2819-
test_name, e
2819+
"Dictionary test '{test_name}' failed: {e}"
28202820
))
28212821
})?;
28222822

28232823
let test_name = int64_case.name;
28242824
run_dictionary_in_list_test(int64_case).map_err(|e| {
28252825
datafusion_common::DataFusionError::Execution(format!(
2826-
"Dictionary test '{}' failed: {}",
2827-
test_name, e
2826+
"Dictionary test '{test_name}' failed: {e}"
28282827
))
28292828
})?;
28302829

28312830
let test_name = float64_case.name;
28322831
run_dictionary_in_list_test(float64_case).map_err(|e| {
28332832
datafusion_common::DataFusionError::Execution(format!(
2834-
"Dictionary test '{}' failed: {}",
2835-
test_name, e
2833+
"Dictionary test '{test_name}' failed: {e}"
28362834
))
28372835
})?;
28382836

@@ -2867,8 +2865,7 @@ mod tests {
28672865
let test_name = dedup_case.name;
28682866
run_dictionary_in_list_test(dedup_case).map_err(|e| {
28692867
datafusion_common::DataFusionError::Execution(format!(
2870-
"Dictionary test '{}' failed: {}",
2871-
test_name, e
2868+
"Dictionary test '{test_name}' failed: {e}"
28722869
))
28732870
})?;
28742871

0 commit comments

Comments
 (0)