You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "MaxGekk (via GitHub)" <gi...@apache.org> on 2023/08/07 07:09:22 UTC
[GitHub] [spark] MaxGekk commented on a diff in pull request #42220: [SPARK-44577][SQL] Fix INSERT BY NAME returns nonsensical error message
MaxGekk commented on code in PR #42220:
URL: https://github.com/apache/spark/pull/42220#discussion_r1285461310
##########
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(", ")
Review Comment:
Fix indentation
##########
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
Review Comment:
Can this be empty `expectedCols.filter(col => !matchedCols.contains(col.name))`? If so, `.head` can fail.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org