wangyum commented on a change in pull request #26499: [SPARK-29869][SQL] Make
error message more meaningful when
HiveMetastoreCatalog#convertToLogicalRelation throws AssertionError
URL: https://github.com/apache/spark/pull/26499#discussion_r345635344
##########
File path:
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
##########
@@ -257,8 +257,16 @@ private[hive] class HiveMetastoreCatalog(sparkSession:
SparkSession) extends Log
}
// The inferred schema may have different field names as the table schema,
we should respect
// it, but also respect the exprId in table relation output.
- assert(result.output.length == relation.output.length &&
- result.output.zip(relation.output).forall { case (a1, a2) => a1.dataType
== a2.dataType })
+ assert(result.output.length == relation.output.length,
+ s"Target table has ${result.output.length} columns, " +
+ s"but source table has ${relation.output.length} columns. " +
+ s"It may need to recreate the table ${relation.tableMeta.identifier}")
+ result.output.zip(relation.output).foreach { case (a1, a2) =>
+ assert(a1.dataType.sameType(a2.dataType),
+ s"Data type of column ${a1.name} in target table is
${a1.dataType.typeName}, " +
+ s"but column ${a2.name} in source table is ${a2.dataType.typeName}.
" +
+ s"It may need to recreate the table
${relation.tableMeta.identifier}")
+ }
Review comment:
Thank you @LantaoJin Could we add a test case?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]