Skip to content

Commit a9d36de

Browse files
committed
[HSTACK] Fix extraneous casts due to invalid type comparison (see apache#19943)
1 parent 359bd6c commit a9d36de

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎datafusion/expr/src/expr_schema.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,11 @@ impl ExprSchemable for Expr {
657657
/// expression to the target [arrow::datatypes::DataType].
658658
fn cast_to(self, cast_to_type: &DataType, schema: &dyn ExprSchema) -> Result<Expr> {
659659
let this_type = self.get_type(schema)?;
660+
// @HStack - see https://github.com/apache/datafusion/issues/19943
661+
// currently we cannot activate this - some failing tests
662+
// at datafusion/datafusion/sqllogictest/test_files/case.slt:389
663+
// datafusion/datafusion/sqllogictest/test_files/case.slt:400
664+
// if this_type.equals_datatype(cast_to_type) {
660665
if this_type == *cast_to_type {
661666
return Ok(self);
662667
}

‎datafusion/optimizer/src/analyzer/type_coercion.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,14 @@ fn coerce_arguments_for_signature_with_scalar_udf(
939939
expressions
940940
.into_iter()
941941
.enumerate()
942-
.map(|(i, expr)| expr.cast_to(&coerced_types[i], schema))
942+
.map(|(i, expr)| {
943+
let current_type = expr.get_type(schema)?;
944+
// @HStack - deep projection fix
945+
if func.name() == "array_element" && current_type.equals_datatype(&coerced_types[i]) {
946+
return Ok(expr)
947+
}
948+
expr.cast_to(&coerced_types[i], schema)
949+
})
943950
.collect()
944951
}
945952

0 commit comments

Comments
 (0)