Hisoka-X commented on code in PR #42220:
URL: https://github.com/apache/spark/pull/42220#discussion_r1296857130


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TableOutputResolver.scala:
##########
@@ -238,11 +238,17 @@ object TableOutputResolver {
 
     if (reordered.length == expectedCols.length) {
       if (matchedCols.size < inputCols.length) {
-        val extraCols = inputCols.filterNot(col => 
matchedCols.contains(col.name))
-          .map(col => s"${toSQLId(col.name)}").mkString(", ")
-        throw 
QueryCompilationErrors.incompatibleDataToTableExtraStructFieldsError(
-          tableName, colPath.quoted, extraCols
-        )
+        if (colPath.isEmpty) {
+          val cannotFindCol = expectedCols.filter(col => 
!matchedCols.contains(col.name)).head.name
+          throw 
QueryCompilationErrors.incompatibleDataToTableCannotFindDataError(tableName,
+            cannotFindCol)
+        } else {
+          val extraCols = inputCols.filterNot(col => 
matchedCols.contains(col.name))
+            .map(col => s"${toSQLId(col.name)}").mkString(", ")
+          throw 
QueryCompilationErrors.incompatibleDataToTableExtraStructFieldsError(

Review Comment:
   It's old behavior, if these are `x int, y int` in struct, and we want add `x 
int, y int, z int` into struct. It will throw `extra fields z` in here. But it 
will not happend on top-level column (It will throw 
`INSERT_COLUMN_ARITY_MISMATCH.TOO_MANY_DATA_COLUMNS`).



-- 
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]

Reply via email to