kramerul commented on code in PR #3562:
URL: https://github.com/apache/calcite/pull/3562#discussion_r1924801559
##########
core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java:
##########
@@ -1424,6 +1430,57 @@ private LockWrapper exclusiveCleanDb(Connection c)
throws SQLException {
+ "GROUP BY \"t2\".\"DNAME\", \"t2\".\"DNAME0\"")
.runs();
}
+
+ /**
+ * Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-4188">[CALCITE-4188]
+ * Support EnumerableBatchNestedLoopJoin for JDBC</a>. */
+ @Test void testBatchNestedLoopJoinPlan() {
+ final String sql = "SELECT *\n"
+ + "FROM \"s\".\"emps\" A\n"
+ + "LEFT OUTER JOIN \"foodmart\".\"store\" B ON A.\"empid\" =
B.\"store_id\"";
+ final String explain = "JdbcFilter(condition=[OR(=($cor0.empid0, $0),
=($cor1.empid0, $0)";
+ final String jdbcSql = "SELECT *\n"
+ + "FROM \"foodmart\".\"store\"\n"
+ + "WHERE ? = \"store_id\" OR (? = \"store_id\" OR ? = \"store_id\") OR
(? = \"store_id\" OR"
+ + " (? = \"store_id\" OR ? = \"store_id\")) OR (? = \"store_id\" OR (?
= \"store_id\" OR ? "
+ + "= \"store_id\") OR (? = \"store_id\" OR (? = \"store_id\" OR ? =
\"store_id\"))) OR (? ="
+ + " \"store_id\" OR (? = \"store_id\" OR ? = \"store_id\") OR (? =
\"store_id\" OR (? = "
+ + "\"store_id\" OR ? = \"store_id\")) OR (? = \"store_id\" OR (? =
\"store_id\" OR ? = "
+ + "\"store_id\") OR (? = \"store_id\" OR ? = \"store_id\" OR (? =
\"store_id\" OR ? = "
+ + "\"store_id\")))) OR (? = \"store_id\" OR (? = \"store_id\" OR ? =
\"store_id\") OR (? = "
+ + "\"store_id\" OR (? = \"store_id\" OR ? = \"store_id\")) OR (? =
\"store_id\" OR (? = "
+ + "\"store_id\" OR ? = \"store_id\") OR (? = \"store_id\" OR (? =
\"store_id\" OR ? = "
+ + "\"store_id\"))) OR (? = \"store_id\" OR (? = \"store_id\" OR ? =
\"store_id\") OR (? = "
+ + "\"store_id\" OR (? = \"store_id\" OR ? = \"store_id\")) OR (? =
\"store_id\" OR (? = "
+ + "\"store_id\" OR ? = \"store_id\") OR (? = \"store_id\" OR ? =
\"store_id\" OR (? = "
+ + "\"store_id\" OR ? = \"store_id\"))))) OR (? = \"store_id\" OR (? =
\"store_id\" OR ? = "
+ + "\"store_id\") OR (? = \"store_id\" OR (? = \"store_id\" OR ? =
\"store_id\")) OR (? = "
+ + "\"store_id\" OR (? = \"store_id\" OR ? = \"store_id\") OR (? =
\"store_id\" OR (? = "
+ + "\"store_id\" OR ? = \"store_id\"))) OR (? = \"store_id\" OR (? =
\"store_id\" OR ? = "
+ + "\"store_id\") OR (? = \"store_id\" OR (? = \"store_id\" OR ? =
\"store_id\")) OR (? = "
+ + "\"store_id\" OR (? = \"store_id\" OR ? = \"store_id\") OR (? =
\"store_id\" OR ? = "
+ + "\"store_id\" OR (? = \"store_id\" OR ? = \"store_id\")))) OR (? =
\"store_id\" OR (? = "
+ + "\"store_id\" OR ? = \"store_id\") OR (? = \"store_id\" OR (? =
\"store_id\" OR ? = "
+ + "\"store_id\")) OR (? = \"store_id\" OR (? = \"store_id\" OR ? =
\"store_id\") OR (? = "
+ + "\"store_id\" OR (? = \"store_id\" OR ? = \"store_id\"))) OR (? =
\"store_id\" OR (? = "
+ + "\"store_id\" OR ? = \"store_id\") OR (? = \"store_id\" OR (? =
\"store_id\" OR ? = "
+ + "\"store_id\")) OR (? = \"store_id\" OR (? = \"store_id\" OR ? =
\"store_id\") OR (? = "
+ + "\"store_id\" OR ? = \"store_id\" OR (? = \"store_id\" OR ? =
\"store_id\"))))))";
+ CalciteAssert.model(FoodmartSchema.FOODMART_MODEL)
+ .withSchema("s", new ReflectiveSchema(new HrSchema()))
+ .withHook(Hook.PLANNER, (Consumer<RelOptPlanner>) planner -> {
+
planner.addRule(EnumerableRules.ENUMERABLE_BATCH_NESTED_LOOP_JOIN_RULE);
+ })
+ .query(sql)
+ .explainContains(explain)
+ .runs()
+ .enable(CalciteAssert.DB == CalciteAssert.DatabaseInstance.HSQLDB
+ || CalciteAssert.DB == DatabaseInstance.POSTGRESQL)
+ .planHasSql(jdbcSql)
+ .returnsCount(4);
+ }
Review Comment:
There is exactly one `JdbcCorrelationDataContextBuilderImpl` instance used
to translate a relation into an SQL statement. All dynamic parameters are local
to this statement. Therefore, it's not possible that the same dynamic parameter
index is used twice in an SQL statement.
--
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]