Skip to content
Closed
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 e17cc594d02129c8348e378e6c1d621a2049181c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.apache.spark.sql.catalyst.dsl.plans._
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.{Count, Max}
import org.apache.spark.sql.catalyst.parser.CatalystSqlParser
import org.apache.spark.sql.catalyst.plans.{Cross, LeftOuter, RightOuter}
import org.apache.spark.sql.catalyst.plans.{AsOfJoinDirection, Cross, Inner, LeftOuter, RightOuter}
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.util.{ArrayBasedMapData, GenericArrayData, MapData}
import org.apache.spark.sql.internal.SQLConf
Expand Down Expand Up @@ -784,8 +784,70 @@ class AnalysisErrorSuite extends AnalysisTest {
val error = intercept[AnalysisException] {
SimpleAnalyzer.checkAnalysis(join)
}
assert(error.message.contains("Failure when resolving conflicting references in Join"))
assert(error.message.contains("Conflicting attributes"))
checkError(
exception = error,
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
parameters = Map(
"nodeName" -> "Join",
"plan" -> "'Join Cross\n:- LocalRelation <empty>, [a#0]\n+- LocalRelation <empty>, [a#0]\n",
"conflictingAttributes" -> "\"a\""
)
)
}

test("error test for self-intersect") {
val intersect = Intersect(testRelation, testRelation, true)
val error = intercept[AnalysisException] {
SimpleAnalyzer.checkAnalysis(intersect)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaxGekk I created test cases use SimpleAnalyzer.checkAnalysis directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see but if you cannot trigger the error from user space, we should convert the error to an internal one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beliefer Could you try to trigger it by from SQL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beliefer Could you try to trigger it by from SQL.

We can't trigger it by SQL. Let me convert it to internal error.

Copy link
Member

@MaxGekk MaxGekk Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @cloud-fan Just to double check that the errors are internal.

}
checkError(
exception = error,
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
parameters = Map(
"nodeName" -> "Intersect All",
"plan" ->
"'Intersect All true\n:- LocalRelation <empty>, [a#0]\n+- LocalRelation <empty>, [a#0]\n",
"conflictingAttributes" -> "\"a\""
)
)
}

test("error test for self-except") {
val except = Except(testRelation, testRelation, true)
val error = intercept[AnalysisException] {
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#0]\n+- LocalRelation <empty>, [a#0]\n",
"conflictingAttributes" -> "\"a\""
)
)
}

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] {
SimpleAnalyzer.checkAnalysis(asOfJoin)
}
val expectedPlan = "'AsOfJoin (a#0 >= a#0), " +
"Inner\n:- LocalRelation <empty>, [a#0]\n+- LocalRelation <empty>, [a#0]\n"
checkError(
exception = error,
errorClass = "RESOLVED_PLAN_HAVE_CONFLICTING_ATTRS",
parameters = Map(
"nodeName" -> "AsOfJoin",
"plan" -> expectedPlan,
"conflictingAttributes" -> "\"a\""
)
)
}

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