gengliangwang commented on a change in pull request #35855:
URL: https://github.com/apache/spark/pull/35855#discussion_r828005515
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveInlineTables.scala
##########
@@ -20,21 +20,31 @@ package org.apache.spark.sql.catalyst.analysis
import scala.util.control.NonFatal
import org.apache.spark.sql.catalyst.InternalRow
-import org.apache.spark.sql.catalyst.plans.logical.{LocalRelation, LogicalPlan}
+import org.apache.spark.sql.catalyst.catalog.SessionCatalog
+import org.apache.spark.sql.catalyst.plans.logical.{InsertIntoStatement,
LocalRelation, LogicalPlan, Project}
import org.apache.spark.sql.catalyst.rules.Rule
import org.apache.spark.sql.catalyst.trees.AlwaysProcess
import org.apache.spark.sql.types.{StructField, StructType}
/**
* An analyzer rule that replaces [[UnresolvedInlineTable]] with
[[LocalRelation]].
*/
-object ResolveInlineTables extends Rule[LogicalPlan] with CastSupport {
+case class ResolveInlineTables(catalog: SessionCatalog) extends
Rule[LogicalPlan] with CastSupport {
override def apply(plan: LogicalPlan): LogicalPlan =
plan.resolveOperatorsWithPruning(
AlwaysProcess.fn, ruleId) {
case table: UnresolvedInlineTable if table.expressionsResolved =>
validateInputDimension(table)
validateInputEvaluable(table)
convert(table)
+ case i @ InsertIntoStatement(_, _, _, (_: UnresolvedInlineTable | _:
Project), _, _) =>
+ // This case matches against an INSERT INTO statement whose right-hand
side is either a
+ // VALUES list (comprising an inline table) or else a SELECT query
(comprising a projection).
+ // In either case, we expect this input to be unresolved at this point
because this
+ // [[ResolveInlineTables]] rule runs top-down. It is necessary to match
against the entire
+ // INSERT INTO statement in this way in order to provide enough context
to know what values
+ // to replace each explicit provided DEFAULT reference with.
+ DefaultColumns.ReplaceExplicitDefaultColumnValues(
Review comment:
How about:
1. filling missing columns with "DEFAULT"
2. replace all the "DEFAULT" as the default column value
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]