github-advanced-security[bot] commented on code in PR #15302:
URL: https://github.com/apache/druid/pull/15302#discussion_r1378716311
##########
sql/src/test/java/org/apache/druid/sql/calcite/CalciteJoinQueryTest.java:
##########
@@ -4559,6 +4526,107 @@
);
}
+ @Test
+ @Parameters(source = QueryContextForJoinProvider.class)
+ public void testJoinWithNonEquiCondition(Map<String, Object> queryContext)
+ {
+ // Native JOIN operator cannot handle the condition, so a SQL JOIN with
greater-than is translated into a
+ // cross join with a filter.
+ cannotVectorize();
+
+ testQuery(
+ "SELECT x.m1, y.m1 FROM foo x INNER JOIN foo y ON x.m1 > y.m1",
+ queryContext,
+ ImmutableList.of(
+ newScanQueryBuilder()
+ .dataSource(
+ join(
+ new TableDataSource(CalciteTests.DATASOURCE1),
+ new QueryDataSource(
+ newScanQueryBuilder()
+ .dataSource(CalciteTests.DATASOURCE1)
+
.intervals(querySegmentSpec(Filtration.eternity()))
+ .columns("m1")
+ .context(queryContext)
+ .build()
+ ),
+ "j0.",
+ "1",
+ JoinType.INNER
+ )
+ )
+ .intervals(querySegmentSpec(Filtration.eternity()))
+ .filters(expressionFilter("(\"m1\" > \"j0.m1\")"))
+ .columns("j0.m1", "m1")
+ .context(queryContext)
+ .build()
+ ),
+ sortIfSortBased(
+ ImmutableList.of(
+ new Object[]{2.0f, 1.0f},
+ new Object[]{3.0f, 1.0f},
+ new Object[]{3.0f, 2.0f},
+ new Object[]{4.0f, 1.0f},
+ new Object[]{4.0f, 2.0f},
+ new Object[]{4.0f, 3.0f},
+ new Object[]{5.0f, 1.0f},
+ new Object[]{5.0f, 2.0f},
+ new Object[]{5.0f, 3.0f},
+ new Object[]{5.0f, 4.0f},
+ new Object[]{6.0f, 1.0f},
+ new Object[]{6.0f, 2.0f},
+ new Object[]{6.0f, 3.0f},
+ new Object[]{6.0f, 4.0f},
+ new Object[]{6.0f, 5.0f}
+ ),
+ 1,
+ 0
+ )
+ );
+ }
+
+ @Test
+ @Parameters(source = QueryContextForJoinProvider.class)
+ public void testJoinWithEquiAndNonEquiCondition(Map<String, Object>
queryContext)
+ {
+ // Native JOIN operator cannot handle the condition, so a SQL JOIN with
greater-than is translated into a
+ // cross join with a filter.
+ cannotVectorize();
+
+ testQuery(
+ "SELECT x.m1, y.m1 FROM foo x INNER JOIN foo y ON x.m1 = y.m1 AND x.m1
+ y.m1 = 6.0",
+ queryContext,
+ ImmutableList.of(
+ newScanQueryBuilder()
+ .dataSource(
+ join(
+ new TableDataSource(CalciteTests.DATASOURCE1),
+ new QueryDataSource(
+ newScanQueryBuilder()
+ .dataSource(CalciteTests.DATASOURCE1)
+
.intervals(querySegmentSpec(Filtration.eternity()))
+ .columns("m1")
+ .context(queryContext)
+ .build()
+ ),
+ "j0.",
+ equalsCondition(makeColumnExpression("m1"),
makeColumnExpression("j0.m1")),
Review Comment:
## Deprecated method or constructor invocation
Invoking [CalciteTestBase.makeColumnExpression](1) should be avoided because
it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5955)
##########
sql/src/test/java/org/apache/druid/sql/calcite/CalciteJoinQueryTest.java:
##########
@@ -1966,17 +1960,17 @@
.build()
),
"_j0.",
- "1",
+ equalsCondition(
+
DruidExpression.fromExpression("CAST(\"j0.k\", 'LONG')"),
Review Comment:
## Deprecated method or constructor invocation
Invoking [DruidExpression.fromExpression](1) should be avoided because it
has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5954)
##########
sql/src/test/java/org/apache/druid/sql/calcite/CalciteJoinQueryTest.java:
##########
@@ -4559,6 +4526,107 @@
);
}
+ @Test
+ @Parameters(source = QueryContextForJoinProvider.class)
+ public void testJoinWithNonEquiCondition(Map<String, Object> queryContext)
+ {
+ // Native JOIN operator cannot handle the condition, so a SQL JOIN with
greater-than is translated into a
+ // cross join with a filter.
+ cannotVectorize();
+
+ testQuery(
+ "SELECT x.m1, y.m1 FROM foo x INNER JOIN foo y ON x.m1 > y.m1",
+ queryContext,
+ ImmutableList.of(
+ newScanQueryBuilder()
+ .dataSource(
+ join(
+ new TableDataSource(CalciteTests.DATASOURCE1),
+ new QueryDataSource(
+ newScanQueryBuilder()
+ .dataSource(CalciteTests.DATASOURCE1)
+
.intervals(querySegmentSpec(Filtration.eternity()))
+ .columns("m1")
+ .context(queryContext)
+ .build()
+ ),
+ "j0.",
+ "1",
+ JoinType.INNER
+ )
+ )
+ .intervals(querySegmentSpec(Filtration.eternity()))
+ .filters(expressionFilter("(\"m1\" > \"j0.m1\")"))
+ .columns("j0.m1", "m1")
+ .context(queryContext)
+ .build()
+ ),
+ sortIfSortBased(
+ ImmutableList.of(
+ new Object[]{2.0f, 1.0f},
+ new Object[]{3.0f, 1.0f},
+ new Object[]{3.0f, 2.0f},
+ new Object[]{4.0f, 1.0f},
+ new Object[]{4.0f, 2.0f},
+ new Object[]{4.0f, 3.0f},
+ new Object[]{5.0f, 1.0f},
+ new Object[]{5.0f, 2.0f},
+ new Object[]{5.0f, 3.0f},
+ new Object[]{5.0f, 4.0f},
+ new Object[]{6.0f, 1.0f},
+ new Object[]{6.0f, 2.0f},
+ new Object[]{6.0f, 3.0f},
+ new Object[]{6.0f, 4.0f},
+ new Object[]{6.0f, 5.0f}
+ ),
+ 1,
+ 0
+ )
+ );
+ }
+
+ @Test
+ @Parameters(source = QueryContextForJoinProvider.class)
+ public void testJoinWithEquiAndNonEquiCondition(Map<String, Object>
queryContext)
+ {
+ // Native JOIN operator cannot handle the condition, so a SQL JOIN with
greater-than is translated into a
+ // cross join with a filter.
+ cannotVectorize();
+
+ testQuery(
+ "SELECT x.m1, y.m1 FROM foo x INNER JOIN foo y ON x.m1 = y.m1 AND x.m1
+ y.m1 = 6.0",
+ queryContext,
+ ImmutableList.of(
+ newScanQueryBuilder()
+ .dataSource(
+ join(
+ new TableDataSource(CalciteTests.DATASOURCE1),
+ new QueryDataSource(
+ newScanQueryBuilder()
+ .dataSource(CalciteTests.DATASOURCE1)
+
.intervals(querySegmentSpec(Filtration.eternity()))
+ .columns("m1")
+ .context(queryContext)
+ .build()
+ ),
+ "j0.",
+ equalsCondition(makeColumnExpression("m1"),
makeColumnExpression("j0.m1")),
Review Comment:
## Deprecated method or constructor invocation
Invoking [CalciteTestBase.makeColumnExpression](1) should be avoided because
it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5956)
--
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]