Skip to content

Commit

Permalink
Add some hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed May 3, 2024
1 parent d467f2f commit 864eec2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion datafusion/optimizer/src/analyzer/type_coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ impl<'a> TreeNodeRewriter for TypeCoercionPlanRewriter<'a> {
self.any_plan_transformed = true;
}

// Hack: For subquery alias need to recompute the schema for unknown reasons
if matches!(transformed_plan.data, LogicalPlan::SubqueryAlias(_)) {
self.any_plan_transformed = true;
}

if self.any_plan_transformed {
transformed_plan
.transform_data(|plan| plan.recompute_schema().map(Transformed::yes))
Expand All @@ -162,6 +167,7 @@ impl<'a> TreeNodeRewriter for TypeCoercionExprRewriter<'a> {
type Node = Expr;

fn f_up(&mut self, expr: Expr) -> Result<Transformed<Expr>> {

match expr {
Expr::Unnest(_) => not_impl_err!(
"Unnest should be rewritten to LogicalPlan::Unnest before type coercion"
Expand Down Expand Up @@ -739,7 +745,10 @@ impl<'a> TypeCoercionExprRewriter<'a> {
}
})
.collect::<Result<Vec<_>>>()?;
caster.build(new_expressions)
// Hack: force the schema to be computed again even if seemingly
// nothing changed
// caster.build(new_expressions)
Ok(Transformed::yes(new_expressions))
} else {
Ok(Transformed::no(expressions))
}
Expand Down

0 comments on commit 864eec2

Please sign in to comment.