cloud-fan commented on code in PR #42220:
URL: https://github.com/apache/spark/pull/42220#discussion_r1278987087
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TableOutputResolver.scala:
##########
@@ -263,16 +268,26 @@ object TableOutputResolver {
val extraColsStr = inputCols.takeRight(inputCols.size -
expectedCols.size)
.map(col => toSQLId(col.name))
.mkString(", ")
- throw
QueryCompilationErrors.incompatibleDataToTableExtraStructFieldsError(
- tableName, colPath.quoted, extraColsStr
- )
+ if (colPath.isEmpty) {
+ throw
QueryCompilationErrors.cannotWriteTooManyColumnsToTableError(tableName,
+ expectedCols.map(_.name), inputCols.map(_.toAttribute))
+ } else {
+ throw
QueryCompilationErrors.incompatibleDataToTableExtraStructFieldsError(
+ tableName, colPath.quoted, extraColsStr
+ )
+ }
} else if (inputCols.size < expectedCols.size) {
val missingColsStr = expectedCols.takeRight(expectedCols.size -
inputCols.size)
.map(col => toSQLId(col.name))
.mkString(", ")
- throw
QueryCompilationErrors.incompatibleDataToTableStructMissingFieldsError(
- tableName, colPath.quoted, missingColsStr
- )
+ if (colPath.isEmpty) {
Review Comment:
this appears three times, we can add a method for it.
--
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]