Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,12 @@
],
"sqlState" : "22012"
},
"DUPLICATED_CTE_NAMES" : {
"message" : [
"CTE definition can't have duplicate names: <duplicateNames>."
],
"sqlState" : "42602"
},
"DUPLICATED_FIELD_NAME_IN_ARROW_STRUCT" : {
"message" : [
"Duplicated field names in Arrow Struct are not allowed, got <fieldNames>."
Expand Down Expand Up @@ -5764,11 +5770,6 @@
"It is not allowed to add catalog/namespace prefix <quoted> to the table name in CACHE TABLE AS SELECT."
]
},
"_LEGACY_ERROR_TEMP_0038" : {
"message" : [
"CTE definition can't have duplicate names: <duplicateNames>."
]
},
"_LEGACY_ERROR_TEMP_0043" : {
"message" : [
"Expected format is 'RESET' or 'RESET key'. If you want to include special characters in key, please use quotes, e.g., RESET `key`."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ private[sql] object QueryParsingErrors extends DataTypeErrorsBase {

def duplicateCteDefinitionNamesError(duplicateNames: String, ctx: CtesContext): Throwable = {
new ParseException(
errorClass = "_LEGACY_ERROR_TEMP_0038",
errorClass = "DUPLICATED_CTE_NAMES",
messageParameters = Map("duplicateNames" -> duplicateNames),
ctx)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ class AstBuilder extends DataTypeAstBuilder
val duplicates = ctes.groupBy(_._1).filter(_._2.size > 1).keys
if (duplicates.nonEmpty) {
throw QueryParsingErrors.duplicateCteDefinitionNamesError(
duplicates.mkString("'", "', '", "'"), ctx)
duplicates.map(toSQLId).mkString(", "), ctx)
}
UnresolvedWith(plan, ctes.toSeq)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ class PlanParserSuite extends AnalysisTest {
val sql = "with cte1 (select 1), cte1 as (select 1 from cte1) select * from cte1"
checkError(
exception = parseException(sql),
condition = "_LEGACY_ERROR_TEMP_0038",
parameters = Map("duplicateNames" -> "'cte1'"),
condition = "DUPLICATED_CTE_NAMES",
parameters = Map("duplicateNames" -> "`cte1`"),
context = ExpectedContext(
fragment = sql,
start = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ SELECT * FROM t
-- !query analysis
org.apache.spark.sql.catalyst.parser.ParseException
{
"errorClass" : "_LEGACY_ERROR_TEMP_0038",
"errorClass" : "DUPLICATED_CTE_NAMES",
"sqlState" : "42602",
"messageParameters" : {
"duplicateNames" : "'t'"
"duplicateNames" : "`t`"
},
"queryContext" : [ {
"objectType" : "",
Expand Down Expand Up @@ -688,9 +689,10 @@ with cte1 as (select 42), cte1 as (select 42) select * FROM cte1
-- !query analysis
org.apache.spark.sql.catalyst.parser.ParseException
{
"errorClass" : "_LEGACY_ERROR_TEMP_0038",
"errorClass" : "DUPLICATED_CTE_NAMES",
"sqlState" : "42602",
"messageParameters" : {
"duplicateNames" : "'cte1'"
"duplicateNames" : "`cte1`"
},
"queryContext" : [ {
"objectType" : "",
Expand Down
10 changes: 6 additions & 4 deletions sql/core/src/test/resources/sql-tests/results/cte.sql.out
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ struct<>
-- !query output
org.apache.spark.sql.catalyst.parser.ParseException
{
"errorClass" : "_LEGACY_ERROR_TEMP_0038",
"errorClass" : "DUPLICATED_CTE_NAMES",
"sqlState" : "42602",
"messageParameters" : {
"duplicateNames" : "'t'"
"duplicateNames" : "`t`"
},
"queryContext" : [ {
"objectType" : "",
Expand Down Expand Up @@ -497,9 +498,10 @@ struct<>
-- !query output
org.apache.spark.sql.catalyst.parser.ParseException
{
"errorClass" : "_LEGACY_ERROR_TEMP_0038",
"errorClass" : "DUPLICATED_CTE_NAMES",
"sqlState" : "42602",
"messageParameters" : {
"duplicateNames" : "'cte1'"
"duplicateNames" : "`cte1`"
},
"queryContext" : [ {
"objectType" : "",
Expand Down