-
- Downloads
[SPARK-18300][SQL] Do not apply foldable propagation with expand as a child.
## What changes were proposed in this pull request? The `FoldablePropagation` optimizer rule, pulls foldable values out from under an `Expand`. This breaks the `Expand` in two ways: - It rewrites the output attributes of the `Expand`. We explicitly define output attributes for `Expand`, these are (unfortunately) considered as part of the expressions of the `Expand` and can be rewritten. - Expand can actually change the column (it will typically re-use the attributes or the underlying plan). This means that we cannot safely propagate the expressions from under an `Expand`. This PR fixes this and (hopefully) other issues by explicitly whitelisting allowed operators. ## How was this patch tested? Added tests to `FoldablePropagationSuite` and to `SQLQueryTestSuite`. Author: Herman van Hovell <hvanhovell@databricks.com> Closes #15857 from hvanhovell/SPARK-18300.
Showing
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala 32 additions, 26 deletions...org/apache/spark/sql/catalyst/optimizer/expressions.scala
- sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FoldablePropagationSuite.scala 23 additions, 4 deletions...ark/sql/catalyst/optimizer/FoldablePropagationSuite.scala
- sql/core/src/test/resources/sql-tests/inputs/group-by.sql 3 additions, 0 deletionssql/core/src/test/resources/sql-tests/inputs/group-by.sql
- sql/core/src/test/resources/sql-tests/results/group-by.sql.out 9 additions, 1 deletion...ore/src/test/resources/sql-tests/results/group-by.sql.out
Please register or sign in to comment