Skip to content

Commit

Permalink
[VL] Enable right and anti join in smj (apache#6449)
Browse files Browse the repository at this point in the history
  • Loading branch information
JkSelf authored Jul 15, 2024
1 parent de26785 commit a8dd354
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,68 @@ class TestOperator extends VeloxWholeStageTransformerSuite with AdaptiveSparkPla
}
}

test("test sort merge join") {
withTable("t1", "t2") {
sql("""
|create table t1 using parquet as
|select cast(id as int) as c1, cast(id as string) c2 from range(100)
|""".stripMargin)
sql("""
|create table t2 using parquet as
|select cast(id as int) as c1, cast(id as string) c2 from range(100) order by c1 desc;
|""".stripMargin)
withSQLConf("spark.gluten.sql.columnar.forceShuffledHashJoin" -> "false") {
runQueryAndCompare(
"""
|select * from t1 inner join t2 on t1.c1 = t2.c1 and t1.c1 > 50;
|""".stripMargin
) {
checkGlutenOperatorMatch[SortMergeJoinExecTransformer]
}
}

withSQLConf("spark.gluten.sql.columnar.forceShuffledHashJoin" -> "false") {
runQueryAndCompare(
"""
|select * from t1 left join t2 on t1.c1 = t2.c1 and t1.c1 > 50;
|""".stripMargin
) {
checkGlutenOperatorMatch[SortMergeJoinExecTransformer]
}
}

withSQLConf("spark.gluten.sql.columnar.forceShuffledHashJoin" -> "false") {
runQueryAndCompare(
"""
|select * from t1 left semi join t2 on t1.c1 = t2.c1 and t1.c1 > 50;
|""".stripMargin
) {
checkGlutenOperatorMatch[SortMergeJoinExecTransformer]
}
}

withSQLConf("spark.gluten.sql.columnar.forceShuffledHashJoin" -> "false") {
runQueryAndCompare(
"""
|select * from t1 right join t2 on t1.c1 = t2.c1 and t1.c1 > 50;
|""".stripMargin
) {
checkGlutenOperatorMatch[SortMergeJoinExecTransformer]
}
}

withSQLConf("spark.gluten.sql.columnar.forceShuffledHashJoin" -> "false") {
runQueryAndCompare(
"""
|select * from t1 left anti join t2 on t1.c1 = t2.c1 and t1.c1 > 50;
|""".stripMargin
) {
checkGlutenOperatorMatch[SortMergeJoinExecTransformer]
}
}
}
}

test("Fix incorrect path by decode") {
val c = "?.+<_>|/"
val path = rootPath + "/test +?.+<_>|"
Expand Down
4 changes: 3 additions & 1 deletion cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -906,11 +906,13 @@ bool SubstraitToVeloxPlanValidator::validate(const ::substrait::JoinRel& joinRel
switch (joinRel.type()) {
case ::substrait::JoinRel_JoinType_JOIN_TYPE_INNER:
case ::substrait::JoinRel_JoinType_JOIN_TYPE_LEFT:
case ::substrait::JoinRel_JoinType_JOIN_TYPE_RIGHT:
case ::substrait::JoinRel_JoinType_JOIN_TYPE_LEFT_SEMI:
case ::substrait::JoinRel_JoinType_JOIN_TYPE_RIGHT_SEMI:
case ::substrait::JoinRel_JoinType_JOIN_TYPE_ANTI:
break;
default:
LOG_VALIDATION_MSG("Sort merge join only support inner, left, left semi and right semi join.");
LOG_VALIDATION_MSG("Sort merge join type is not supported: " + std::to_string(joinRel.type()));
return false;
}
}
Expand Down

0 comments on commit a8dd354

Please sign in to comment.