zhangxffff commented on code in PR #20444:
URL: https://github.com/apache/datafusion/pull/20444#discussion_r2833555998
##########
datafusion/physical-expr/benches/in_list.rs:
##########
@@ -219,6 +222,144 @@ fn bench_realistic_mixed_strings<A>(
}
}
+/// Benchmarks the dynamic evaluation path (no static filter) by including
+/// a column reference in the IN list, which prevents static filter creation.
+fn do_bench_dynamic(
+ c: &mut Criterion,
+ name: &str,
+ values: ArrayRef,
+ list_cols: &[ArrayRef],
+) {
+ let mut fields = vec![Field::new("a", values.data_type().clone(), true)];
+ let mut columns: Vec<ArrayRef> = vec![values];
+
+ // Build list expressions: mix of column refs (forces dynamic path)
+ let schema_fields: Vec<Field> = list_cols
+ .iter()
+ .enumerate()
+ .map(|(i, col_arr)| {
+ let name = format!("b{i}");
+ fields.push(Field::new(&name, col_arr.data_type().clone(), true));
+ columns.push(Arc::clone(col_arr));
+ Field::new(&name, col_arr.data_type().clone(), true)
+ })
+ .collect();
+
+ let schema = Schema::new(fields);
+ let list_exprs: Vec<Arc<dyn PhysicalExpr>> = schema_fields
+ .iter()
+ .map(|f| col(f.name(), &schema).unwrap())
+ .collect();
+
+ let expr = in_list(col("a", &schema).unwrap(), list_exprs, &false,
&schema).unwrap();
+ let batch = RecordBatch::try_new(Arc::new(schema), columns).unwrap();
+
+ c.bench_function(name, |b| {
+ b.iter(|| black_box(expr.evaluate(black_box(&batch)).unwrap()))
+ });
+}
+
+/// Benchmarks the dynamic IN list path for Int32 arrays with column
references.
Review Comment:
Added equivalent SQL examples to both bench_with_columns_int32 and
bench_with_columns_utf8:
```
/// Equivalent SQL:
/// ```sql
/// CREATE TABLE t (a INT, b0 INT, b1 INT, ...);
/// SELECT * FROM t WHERE a IN (b0, b1, ...);
/// ```
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]