francesco-gini88 commented on a change in pull request #2620:
URL: https://github.com/apache/calcite/pull/2620#discussion_r771798236
##########
File path: core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
##########
@@ -50,23 +50,25 @@
* same time. */
private static final ReentrantLock LOCK = new ReentrantLock();
- /** VALUES is not pushed down, currently. */
+ /** VALUES is pushed down. */
@Test void testValuesPlan() {
final String sql = "select * from \"days\", (values 1, 2) as t(c)";
- final String explain = "PLAN="
- + "EnumerableNestedLoopJoin(condition=[true], joinType=[inner])\n"
- + " JdbcToEnumerableConverter\n"
+ final String explain = "PLAN=JdbcToEnumerableConverter\n"
+ + " JdbcJoin(condition=[true], joinType=[inner])\n"
+ " JdbcTableScan(table=[[foodmart, days]])\n"
- + " EnumerableValues(tuples=[[{ 1 }, { 2 }]])";
+ + " JdbcValues(tuples=[[{ 1 }, { 2 }]])";
Review comment:
@amaliujia my understanding is that Values is pushed down because in
that way the join is also pushed down. What's changed is that now the join can
be pushed down, because it is a cross join and
```
case LITERAL:
// literal on a join condition would be TRUE or FALSE
return true;
```
the condition is always the literal true.
Therefore I figure the planner is picking the plan where the join is pushed
down (generally speaking might be better to push down the join, although maybe
not this particular case) and consequently the Values are also pushed down. For
this reason I don't think a TODO belongs to that part of the code. I think a
Jira describing exactly in which cases/queries Values should not be pushed down
would be a better alternative.
I'm happy to add a join condition if that makes the test clearer.
```
select * from \"days\", (values 1, 2) as t(c) where \"day\" = t.c
```
A query like this one wouldn't be affected by my change (the join condition
is not a literal) and the Values would still be pushed down
--
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]