Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update code
  • Loading branch information
beliefer committed Jun 23, 2023
commit 15987f98179d38ba8b7cadd90e6c22945e7b81fc
7 changes: 0 additions & 7 deletions core/src/main/resources/error/error-classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -1978,13 +1978,6 @@
],
"sqlState" : "42K05"
},
"RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS" : {
"message" : [
"Failure when resolving conflicting references in <nodeName>:",
"<plan>",
"Conflicting attributes: <conflictingAttributes>."
]
},
"ROUTINE_ALREADY_EXISTS" : {
"message" : [
"Cannot create the function <routineName> because it already exists.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,40 +688,48 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog with QueryErrorsB
})

case j: Join if !j.duplicateResolved =>
val conflictingAttributes = j.left.outputSet.intersect(j.right.outputSet)
j.failAnalysis(
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
messageParameters = Map(
"nodeName" -> j.nodeName,
"plan" -> planToString(plan),
"conflictingAttributes" -> conflictingAttributes.map(toSQLExpr(_)).mkString(", ")))
val conflictingAttributes =
j.left.outputSet.intersect(j.right.outputSet).map(toSQLExpr(_)).mkString(", ")
throw SparkException.internalError(
msg = s"""
|Failure when resolving conflicting references in ${j.nodeName}:
|${plan.toString}
|Conflicting attributes: $conflictingAttributes.""",
context = j.origin.getQueryContext,
summary = j.origin.context.summary)

case i: Intersect if !i.duplicateResolved =>
val conflictingAttributes = i.left.outputSet.intersect(i.right.outputSet)
i.failAnalysis(
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
messageParameters = Map(
"nodeName" -> i.nodeName,
"plan" -> planToString(plan),
"conflictingAttributes" -> conflictingAttributes.map(toSQLExpr(_)).mkString(", ")))
val conflictingAttributes =
i.left.outputSet.intersect(i.right.outputSet).map(toSQLExpr(_)).mkString(", ")
throw SparkException.internalError(
msg = s"""
|Failure when resolving conflicting references in ${i.nodeName}:
|${plan.toString}
|Conflicting attributes: $conflictingAttributes.""",
context = i.origin.getQueryContext,
summary = i.origin.context.summary)

case e: Except if !e.duplicateResolved =>
val conflictingAttributes = e.left.outputSet.intersect(e.right.outputSet)
e.failAnalysis(
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
messageParameters = Map(
"nodeName" -> e.nodeName,
"plan" -> planToString(plan),
"conflictingAttributes" -> conflictingAttributes.map(toSQLExpr(_)).mkString(", ")))
val conflictingAttributes =
e.left.outputSet.intersect(e.right.outputSet).map(toSQLExpr(_)).mkString(", ")
throw SparkException.internalError(
msg = s"""
|Failure when resolving conflicting references in ${e.nodeName}:
|${plan.toString}
|Conflicting attributes: $conflictingAttributes.""",
context = e.origin.getQueryContext,
summary = e.origin.context.summary)

case j: AsOfJoin if !j.duplicateResolved =>
val conflictingAttributes = j.left.outputSet.intersect(j.right.outputSet)
j.failAnalysis(
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
messageParameters = Map(
"nodeName" -> j.nodeName,
"plan" -> planToString(plan),
"conflictingAttributes" -> conflictingAttributes.map(toSQLExpr(_)).mkString(",")))
val conflictingAttributes =
j.left.outputSet.intersect(j.right.outputSet).map(toSQLExpr(_)).mkString(", ")
throw SparkException.internalError(
msg = s"""
|Failure when resolving conflicting references in ${j.nodeName}:
|${plan.toString}
|Conflicting attributes: $conflictingAttributes.""",
context = j.origin.getQueryContext,
summary = j.origin.context.summary)

// TODO: although map type is not orderable, technically map type should be able to be
// used in equality comparison, remove this type check once we support it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,73 +781,43 @@ class AnalysisErrorSuite extends AnalysisTest {

test("error test for self-join") {
val join = Join(testRelation, testRelation, Cross, None, JoinHint.NONE)
val error = intercept[AnalysisException] {
val error = intercept[SparkException] {
SimpleAnalyzer.checkAnalysis(join)
}
checkError(
exception = error,
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
parameters = Map(
"nodeName" -> "Join",
"plan" -> "'Join Cross\n:- LocalRelation <empty>, [a#x]\n+- LocalRelation <empty>, [a#x]\n",
"conflictingAttributes" -> "\"a\""
)
)
assert(error.getMessage.contains("Failure when resolving conflicting references in Join"))
assert(error.getMessage.contains("Conflicting attributes"))
}

test("error test for self-intersect") {
val intersect = Intersect(testRelation, testRelation, true)
val error = intercept[AnalysisException] {
val error = intercept[SparkException] {
SimpleAnalyzer.checkAnalysis(intersect)
}
checkError(
exception = error,
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
parameters = Map(
"nodeName" -> "Intersect All",
"plan" ->
"'Intersect All true\n:- LocalRelation <empty>, [a#x]\n+- LocalRelation <empty>, [a#x]\n",
"conflictingAttributes" -> "\"a\""
)
)
assert(error.getMessage.contains(
"Failure when resolving conflicting references in Intersect All"))
assert(error.getMessage.contains("Conflicting attributes"))
}

test("error test for self-except") {
val except = Except(testRelation, testRelation, true)
val error = intercept[AnalysisException] {
val error = intercept[SparkException] {
SimpleAnalyzer.checkAnalysis(except)
}
checkError(
exception = error,
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
parameters = Map(
"nodeName" -> "Except All",
"plan" ->
"'Except All true\n:- LocalRelation <empty>, [a#x]\n+- LocalRelation <empty>, [a#x]\n",
"conflictingAttributes" -> "\"a\""
)
)
assert(error.getMessage.contains(
"Failure when resolving conflicting references in Except All"))
assert(error.getMessage.contains("Conflicting attributes"))
}

test("error test for self-asOfJoin") {
val asOfJoin =
AsOfJoin(testRelation, testRelation, testRelation.output(0), testRelation.output(0),
None, Inner, tolerance = None, allowExactMatches = true,
direction = AsOfJoinDirection("backward"))
val error = intercept[AnalysisException] {
val error = intercept[SparkException] {
SimpleAnalyzer.checkAnalysis(asOfJoin)
}
val expectedPlan = "'AsOfJoin (a#x >= a#x), " +
"Inner\n:- LocalRelation <empty>, [a#x]\n+- LocalRelation <empty>, [a#x]\n"
checkError(
exception = error,
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
parameters = Map(
"nodeName" -> "AsOfJoin",
"plan" -> expectedPlan,
"conflictingAttributes" -> "\"a\""
)
)
assert(error.getMessage.contains("Failure when resolving conflicting references in AsOfJoin"))
assert(error.getMessage.contains("Conflicting attributes"))
}

test("check grouping expression data types") {
Expand Down