ResolveDefaultColumns Logical Resolution Rule¶
ResolveDefaultColumns
is a logical resolution rule (a Rule to transform a LogicalPlan) that resolves the following operators (top-down):
ResolveDefaultColumns
is executed only when spark.sql.defaultColumn.enabled is enabled.
ResolveDefaultColumns
is part of the Resolution fixed-point rule batch of the Analyzer.
Creating Instance¶
ResolveDefaultColumns
takes the following to be created:
ResolveDefaultColumns
is created when:
Analyzer
is requested for the batches
Executing Rule¶
Noop with spark.sql.defaultColumn.enabled
disabled
ResolveDefaultColumns
does nothing and returns the logical plan in-tact when spark.sql.defaultColumn.enabled is disabled.
With spark.sql.defaultColumn.enabled enabled, apply
resolves the following operators (top-down):
InsertIntoStatement¶
For InsertIntoStatements that insertsFromInlineTable, apply
resolveDefaultColumnsForInsertFromInlineTable.
For InsertIntoStatements with a Project query that is not a Star
, apply
resolveDefaultColumnsForInsertFromProject.
UpdateTable¶
For UpdateTables, apply
resolveDefaultColumnsForUpdate.
MergeIntoTable¶
For MergeIntoTables, apply
resolveDefaultColumnsForMerge.
constantFoldCurrentDefaultsToExistDefaults¶
constantFoldCurrentDefaultsToExistDefaults(
tableSchema: StructType,
statementType: String): StructType
Only with spark.sql.defaultColumn.enabled enabled, constantFoldCurrentDefaultsToExistDefaults
...FIXME
Otherwise, constantFoldCurrentDefaultsToExistDefaults
does nothing (a noop) and returns the given table schema intact.
constantFoldCurrentDefaultsToExistDefaults
is used when:
CatalogV2Util
is requested to addField- AlterTableAddColumnsCommand logical command is executed (to constantFoldCurrentDefaultsToExistDefaults)
- DataSourceAnalysis logical resolution rule is executed (to resolve a CreateTable logical operator with a DataSource table)
- DataSourceV2Strategy execution planning strategy is executed (to resolve CreateTable and
ReplaceTable
logical operators)