SubPlan Pushdown#186
Conversation
59c6eda to
92be51e
Compare
837e202 to
689716a
Compare
6d9cdbc to
6e4eeaf
Compare
| } | ||
| } | ||
| if (!found) | ||
| elog(ERROR, "no ANY_SUBLINK alternative for pushdown"); |
There was a problem hiding this comment.
should be ereport, would like to get this cleaned up across codebase after http streaming lands
73bc318 to
e30acbb
Compare
theory
left a comment
There was a problem hiding this comment.
I pushed a commit that executes the fully pushed-down query. It fails. I suspect we need to do some sort of jiggerpokery to generate new aliases in the subquery and then to reference tables in the outer query.
| Foreign Scan on subquery_test.spd_orders | ||
| Output: spd_orders.id, spd_orders.status | ||
| Remote SQL: SELECT id, status FROM subquery_test.spd_orders WHERE ((id IN (SELECT order_id FROM subquery_test.items) OR (status = 'closed'))) ORDER BY id ASC NULLS LAST | ||
| SubPlan 2 | ||
| -> Foreign Scan on subquery_test.items | ||
| Output: items.order_id | ||
| Remote SQL: SELECT order_id FROM subquery_test.items |
There was a problem hiding this comment.
Can this and the other queries in this file not be pushed down as a single ClickHouse query?
| if (subplan->subLinkType != ANY_SUBLINK && | ||
| subplan->subLinkType != EXISTS_SUBLINK && | ||
| subplan->subLinkType != EXPR_SUBLINK) |
There was a problem hiding this comment.
So, no support for CTEs (yet)? What about the others?
| return false; | ||
| } | ||
|
|
||
| /* Reject nested SubPlans (correlated or InitPlan) */ |
| if (first) | ||
| appendStringInfoChar(buf, '1'); | ||
|
|
||
| /* FROM clause */ |
There was a problem hiding this comment.
Are we unable to use the existing deparsers for these clauses? deparseFromExprForRel() or deparseFromExpr(), deparseSortGroupClause(), etc.?
Demonstrate that it fails due to improper table aliasing.
3155369 to
73bbcf8
Compare
| * CTE_SUBLINK Recursive/materialised CTE survives | ||
| * past inline_cte_walker; CH cannot host. |
There was a problem hiding this comment.
What does this mean? Possible to support in the future? What would it take?
There was a problem hiding this comment.
we're operating on AST after some optimizations, CTE_SUBLINK at this point is complicated enough to not be optimized
CH does not support recursive CTE: https://clickhouse.com/docs/sql-reference/statements/select/with
Recursion is prevented by hiding the current CTE from the identifier resolution process.
There was a problem hiding this comment.
Yeah, would be nice to support non-recursive CTE in the future.
| * ALL_SUBLINK CH lacks ALL; would need NOT EXISTS | ||
| * rewrite. NOT IN already arrives as | ||
| * NOT(ANY_SUBLINK). | ||
| * ROWCOMPARE_SUBLINK Multi-column compare not deparsed. |
There was a problem hiding this comment.
Could they be? What would need to change?
There was a problem hiding this comment.
they could be, but will require more intrusive deparsing logic, on CH I think it could work by converting to using tuples. but seems best to have initial PR manage dealing with pg subplan logic where syntax is pretty 1:1, then followup can expand
|
failed experiment, may be used as a reference by some future attempt |
rebased #126 & got working with tests