Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yaooqinn committed Nov 27, 2020
1 parent 36bada6 commit 833ac41
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3129,17 +3129,17 @@ class Analyzer(override val catalogManager: CatalogManager)
tableOutput: Seq[Attribute],
cols: Seq[NamedExpression],
query: LogicalPlan): LogicalPlan = {

if (cols.size != query.output.size) {
query.failAnalysis(
s"""Cannot write to table due to mismatched user specified columns and data columns:
|Specified columns: ${cols.map(c => s"'${c.name}'").mkString(", ")}
|Data columns: ${query.output.map(c => s"'${c.name}'").mkString(", ")}"""
.stripMargin)
}

val nameToQueryExpr = cols.zip(query.output).toMap
val reordered = tableOutput.flatMap {nameToQueryExpr.get(_).orElse(None) }
// Static partition columns in the table output should not appear in the column list
// they will be handled in another rule ResolveInsertInto
val reordered = tableOutput.flatMap { nameToQueryExpr.get(_).orElse(None) }
if (reordered == query.output) {
query
} else {
Expand Down

0 comments on commit 833ac41

Please sign in to comment.