From 5868b25278a516cbb7b8504af48a79320e167ae9 Mon Sep 17 00:00:00 2001 From: Xianjin YE Date: Sun, 10 Mar 2024 18:33:19 +0800 Subject: [PATCH] fallback to the previous if the in_list fails --- core/src/execution/datafusion/planner.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/execution/datafusion/planner.rs b/core/src/execution/datafusion/planner.rs index 7ba891918..e213f57ed 100644 --- a/core/src/execution/datafusion/planner.rs +++ b/core/src/execution/datafusion/planner.rs @@ -27,9 +27,9 @@ use datafusion::{ physical_expr::{ execution_props::ExecutionProps, expressions::{ - in_list, BinaryExpr, CaseExpr, CastExpr, Column, Count, FirstValue, IsNotNullExpr, - IsNullExpr, LastValue, Literal as DataFusionLiteral, Max, Min, NegativeExpr, NotExpr, - Sum, UnKnownColumn, + in_list, BinaryExpr, CaseExpr, CastExpr, Column, Count, FirstValue, InListExpr, + IsNotNullExpr, IsNullExpr, LastValue, Literal as DataFusionLiteral, Max, Min, + NegativeExpr, NotExpr, Sum, UnKnownColumn, }, functions::create_physical_expr, AggregateExpr, PhysicalExpr, PhysicalSortExpr, ScalarFunctionExpr, @@ -493,7 +493,16 @@ impl PhysicalPlanner { .iter() .map(|x| self.create_expr(x, input_schema.clone()).unwrap()) .collect::>(); - in_list(value, list, &expr.negated, input_schema.as_ref()).map_err(|e| e.into()) + // in_list doesn't handle value being dictionary type correctly, so we need to fall + // back to InListExpr if in_list fails. + // TODO: remove the fallback when https://github.com/apache/arrow-datafusion/issues/9530 is fixed + in_list( + value.clone(), + list.clone(), + &expr.negated, + input_schema.as_ref(), + ) + .or_else(|_| Ok(Arc::new(InListExpr::new(value, list, expr.negated, None)))) } ExprStruct::If(expr) => { let if_expr =