dongkelun commented on a change in pull request #3415:
URL: https://github.com/apache/hudi/pull/3415#discussion_r686883225
##########
File path:
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/analysis/HoodieAnalysis.scala
##########
@@ -142,11 +142,24 @@ case class HoodieResolveReferences(sparkSession:
SparkSession) extends Rule[Logi
val resolvedCondition =
condition.map(resolveExpressionFrom(resolvedSource)(_))
val resolvedAssignments = if (isInsertOrUpdateStar(assignments)) {
// assignments is empty means insert * or update set *
- // we fill assign all the source fields to the target fields
- target.output
- .filter(attr => !HoodieSqlUtils.isMetaField(attr.name))
- .zip(resolvedSource.output.filter(attr =>
!HoodieSqlUtils.isMetaField(attr.name)))
- .map { case (targetAttr, sourceAttr) => Assignment(targetAttr,
sourceAttr) }
+ val resolvedSourceOutputWithoutMetaFields =
resolvedSource.output.filter(attr => !HoodieSqlUtils.isMetaField(attr.name))
+ val targetOutputWithoutMetaFields = target.output.filter(attr =>
!HoodieSqlUtils.isMetaField(attr.name))
+ val resolvedSourceColumnNamesWithoutMetaFields =
resolvedSourceOutputWithoutMetaFields.map(attr => attr.name)
+
+ if(targetOutputWithoutMetaFields.filter(attr =>
resolvedSourceColumnNamesWithoutMetaFields.contains(attr.name)).length
+ == targetOutputWithoutMetaFields.length) {
+ //If sourceTable's columns contains all targetTable's columns,
+ //We fill assign all the source fields to the target fields by
column name matching.
+ targetOutputWithoutMetaFields.map(targetAttr => {
+ val sourceAttr =
resolvedSourceOutputWithoutMetaFields.filter(attr =>
attr.name.equals(targetAttr.name)).head
Review comment:
Hello, is that right?
`val sourceColNameAttrMap = resolvedSourceOutputWithoutMetaFields.map(attr
=> (attr.name,attr)).toMap
val sourceAttr = sourceColNameAttrMap.get(targetAttr.name).get
`
--
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]