Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-48033][SQL] Fix
RuntimeReplaceable
expressions being used in…
… default columns ### What changes were proposed in this pull request? Currently, default columns that have a default of a `RuntimeReplaceable` expression fails. This is because the `AlterTableCommand` constant folds before replacing expressions with the actual implementation. For example: ``` sql(s"CREATE TABLE t(v VARIANT DEFAULT parse_json('1')) USING PARQUET") sql("INSERT INTO t VALUES(DEFAULT)") ``` fails because `parse_json` is `RuntimeReplaceable` and is evaluated before the analyzer inserts the correct expression into the plan To fix this, we run the `ReplaceExpressions` rule before `ConstantFolding` ### Why are the changes needed? This allows default columns to use expressions that are `RuntimeReplaceable` This is especially important for Variant types because literal variants are difficult to create - `parse_json` will likely be used the majority of the time. ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? added UT ### Was this patch authored or co-authored using generative AI tooling? no Closes #46269 from richardc-db/fix_default_cols_runtime_replaceable. Authored-by: Richard Chen <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
- Loading branch information