Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public UnresolvedPlan visitJoinCommand(OpenSearchPPLParser.JoinCommandContext ct
Argument.ArgumentMap argumentMap = Argument.ArgumentMap.of(arguments);
if (argumentMap.get("type") != null) {
Join.JoinType joinTypeFromArgument = ArgumentFactory.getJoinType(argumentMap);
if (sqlLike && joinType != joinTypeFromArgument) {
if (sqlLike && joinType != joinTypeFromArgument && ctx.sqlLikeJoinType() != null) {
throw new SemanticCheckException(
"Join type is ambiguous, remove either the join type before JOIN keyword or 'type='"
+ " option.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1068,4 +1068,26 @@ public void testJoinWithMaxLessThanZero() {
Throwable t = Assert.assertThrows(SemanticCheckException.class, () -> getRelNode(ppl));
verifyErrorMessageContains(t, "max option must be a positive integer");
}

@Test
public void testSqlLikeJoinWithSpecificJoinType() {
String ppl = "source=EMP | join type=left left=l right=r on l.DEPTNO=r.DEPTNO DEPT";
RelNode root = getRelNode(ppl);
String expectedLogical =
"LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5],"
+ " COMM=[$6], DEPTNO=[$7], r.DEPTNO=[$8], DNAME=[$9], LOC=[$10])\n"
+ " LogicalJoin(condition=[=($7, $8)], joinType=[left])\n"
+ " LogicalTableScan(table=[[scott, EMP]])\n"
+ " LogicalTableScan(table=[[scott, DEPT]])\n";
verifyLogical(root, expectedLogical);
verifyResultCount(root, 14);

String expectedSparkSql =
"SELECT `EMP`.`EMPNO`, `EMP`.`ENAME`, `EMP`.`JOB`, `EMP`.`MGR`, `EMP`.`HIREDATE`,"
+ " `EMP`.`SAL`, `EMP`.`COMM`, `EMP`.`DEPTNO`, `DEPT`.`DEPTNO` `r.DEPTNO`,"
+ " `DEPT`.`DNAME`, `DEPT`.`LOC`\n"
+ "FROM `scott`.`EMP`\n"
+ "LEFT JOIN `scott`.`DEPT` ON `EMP`.`DEPTNO` = `DEPT`.`DEPTNO`";
verifyPPLToSparkSQL(root, expectedSparkSql);
}
}
Loading