aokolnychyi commented on code in PR #50631: URL: https://github.com/apache/spark/pull/50631#discussion_r2054450115
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTableSpec.scala: ########## @@ -46,20 +47,55 @@ object ResolveTableSpec extends Rule[LogicalPlan] { preparedPlan.resolveOperatorsWithPruning(_.containsAnyPattern(COMMAND), ruleId) { case t: CreateTable => - resolveTableSpec(t, t.tableSpec, s => t.copy(tableSpec = s)) + resolveTableSpec(t, t.tableSpec, + fakeRelationFromColumns(t.columns), s => t.copy(tableSpec = s)) case t: CreateTableAsSelect => - resolveTableSpec(t, t.tableSpec, s => t.copy(tableSpec = s)) + resolveTableSpec(t, t.tableSpec, None, s => t.copy(tableSpec = s)) case t: ReplaceTable => - resolveTableSpec(t, t.tableSpec, s => t.copy(tableSpec = s)) + resolveTableSpec(t, t.tableSpec, + fakeRelationFromColumns(t.columns), s => t.copy(tableSpec = s)) case t: ReplaceTableAsSelect => - resolveTableSpec(t, t.tableSpec, s => t.copy(tableSpec = s)) + resolveTableSpec(t, t.tableSpec, None, s => t.copy(tableSpec = s)) } } + private def fakeRelationFromColumns(columns: Seq[ColumnDefinition]): Option[LogicalPlan] = { + val attributeList = columns.map { col => + AttributeReference(col.name, col.dataType)() + } + Some(LocalRelation(attributeList)) + } + + private def analyzeConstraints( Review Comment: Is there any other way to do this? Can we restructure the plan so that the analyzer naturally resolves these expressions? I like that we pivoted to `DefaultValueExpression` for default values, rather than using a custom analyzer. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org