Hisoka-X commented on code in PR #42220:
URL: https://github.com/apache/spark/pull/42220#discussion_r1279004638
##########
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:
Yep, but the error be throwed not same on each case. Add a method only can
extract `if` statement, are we still should to do this?
--
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]