MaxGekk commented on code in PR #48774:
URL: https://github.com/apache/spark/pull/48774#discussion_r1835463819
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala:
##########
@@ -1795,43 +1825,40 @@ class CollationSuite extends DatasourceV2SQLBase with
AdaptiveSparkPlanHelper {
Seq(Row(Row(Seq(Row("aa"))), 1, Row(Seq(Row("AA "))), 2),
Row(Row(Seq(Row("aa"))), 1, Row(Seq(Row("aa"))), 2)))
)
- testCases.foreach(t => {
- withTable(t1, t2) {
- sql(s"CREATE TABLE $t1 (x STRUCT<f:ARRAY<STRUCT<f:STRING COLLATE
${t.collation}>>>, " +
- s"i int) USING PARQUET")
- sql(s"INSERT INTO $t1 VALUES (named_struct('f',
array(named_struct('f', '${t.data1}'))), 1)"
- )
-
- sql(s"CREATE TABLE $t2 (y STRUCT<f:ARRAY<STRUCT<f:STRING COLLATE
${t.collation}>>>, " +
- s"j int) USING PARQUET")
- sql(s"INSERT INTO $t2 VALUES (named_struct('f',
array(named_struct('f', '${t.data2}'))), 2)"
- + s", (named_struct('f', array(named_struct('f', '${t.data1}'))),
2)")
-
- val df = sql(s"SELECT * FROM $t1 JOIN $t2 ON $t1.x = $t2.y")
- checkAnswer(df, t.result)
-
- val queryPlan = df.queryExecution.executedPlan
-
- // confirm that hash join is used instead of sort merge join
- assert(
- collectFirst(queryPlan) {
- case _: HashJoin => ()
- }.nonEmpty
- )
- assert(
- collectFirst(queryPlan) {
- case _: ShuffledJoin => ()
- }.isEmpty
- )
- // Only if collation doesn't support binary equality, collation key
should be injected.
- if (!CollationFactory.fetchCollation(t.collation).isUtf8BinaryType) {
- assert(queryPlan.toString().contains("collationkey"))
- } else {
- assert(!queryPlan.toString().contains("collationkey"))
+ for {
+ t <- testCases
+ broadcastJoinThreshold <- Seq(-1,
SQLConf.get.getConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD))
+ } {
+ withTable(t1, t2) {
+ withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key ->
broadcastJoinThreshold.toString) {
+ sql(s"CREATE TABLE $t1 (x STRUCT<f:ARRAY<STRUCT<f:STRING COLLATE
${t.collation}>>>, " +
+ s"i int) USING PARQUET")
+ sql(s"INSERT INTO $t1 VALUES (named_struct('f',
array(named_struct('f', " +
+ s"'${t.data1}'))), 1)")
+
+ sql(s"CREATE TABLE $t2 (y STRUCT<f:ARRAY<STRUCT<f:STRING COLLATE
${t.collation}>>>, " +
+ s"j int) USING PARQUET")
+ sql(s"INSERT INTO $t2 VALUES (named_struct('f',
array(named_struct('f', " +
+ s"'${t.data2}'))), 2), (named_struct('f', array(named_struct('f',
'${t.data1}'))), 2)")
+
+ val df = sql(s"SELECT * FROM $t1 JOIN $t2 ON $t1.x = $t2.y")
+ checkAnswer(df, t.result)
+
+ val queryPlan = df.queryExecution.executedPlan
+
+ // confirm that right kind of join is used.
+ checkRightTypeOfJoinUsed(queryPlan)
+
+ // Only if collation doesn't support binary equality, collation key
should be injected.
+ if
(!CollationFactory.fetchCollation(t.collation).supportsBinaryEquality) {
+ assert(queryPlan.toString().contains("collationkey"))
+ } else {
+ assert(!queryPlan.toString().contains("collationkey"))
+ }
Review Comment:
Could you place the common code to a helper function.
--
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]