panbingkun commented on code in PR #38861:
URL: https://github.com/apache/spark/pull/38861#discussion_r1051553117
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala:
##########
@@ -2019,14 +2008,27 @@ private[sql] object QueryCompilationErrors extends
QueryErrorsBase {
"dataColumns" -> query.output.map(c => s"'${c.name}'").mkString(", ")))
}
- def cannotWriteNotEnoughColumnsToTableError(
- tableName: String, expected: Seq[Attribute], query: LogicalPlan):
Throwable = {
+ def insertMismatchedColumnNumberError(
+ firstNumColumns: Int,
+ invalidOrdinalNum: Int,
+ invalidNumColumns: Int): Throwable = {
+
+ def ordinalNumber(i: Int): String = i match {
+ case 0 => "first"
+ case 1 => "second"
+ case 2 => "third"
+ case i => s"${i + 1}th"
+ }
+
new AnalysisException(
- errorClass = "_LEGACY_ERROR_TEMP_1203",
+ errorClass = "NUM_COLUMNS_MISMATCH",
messageParameters = Map(
- "tableName" -> tableName,
- "tableColumns" -> expected.map(c => s"'${c.name}'").mkString(", "),
- "dataColumns" -> query.output.map(c => s"'${c.name}'").mkString(", ")))
+ "operator" -> "INSERT INTO",
+ "firstNumColumns" -> firstNumColumns.toString,
+ "invalidOrdinalNum" -> ordinalNumber(invalidOrdinalNum + 1),
Review Comment:
Done. This is really weird, let me modify it more reasonably.
--
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]