Repository navigation
Adding CrossJoinNode to QueryTree - #72856
Conversation
|
This is an automated comment for commit 0033793 with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
| /** Construct join node with left table expression, right table expression and join expression. | ||
| * Example: SELECT id FROM test_table_1 INNER JOIN test_table_2 ON expression. | ||
| * | ||
| * test_table_1 - left table expression. | ||
| * test_table_2 - right table expression. | ||
| * expression - join expression. | ||
| */ |
There was a problem hiding this comment.
| /** Construct join node with left table expression, right table expression and join expression. | |
| * Example: SELECT id FROM test_table_1 INNER JOIN test_table_2 ON expression. | |
| * | |
| * test_table_1 - left table expression. | |
| * test_table_2 - right table expression. | |
| * expression - join expression. | |
| */ | |
| /** Construct join node with the list of table expressions: | |
| * Example: SELECT * FROM t1, t2, t3 | |
| * t1, t2, t3 - list of table expressions | |
| */ |
|
|
||
| if (const auto * /*cross_join_node*/ _ = node->as<CrossJoinNode>()) | ||
| { | ||
| can_wrap_result_columns_with_nullable |= getContext()->getSettingsRef()[Setting::join_use_nulls]; |
There was a problem hiding this comment.
Actually, we do not convert to nullable in the case of a cross join. However, it should also check the join kind above as well (i.e., do not convert for inner). It seems we just won’t apply certain optimizations if we set this flag to conservative, correct?
There was a problem hiding this comment.
I think so.
So far, I have disabled it for a cross-join the same way it was.
Let's check join kind in the separate PR.
|
|
||
| QueryTreeNodes & getTableExpressions() | ||
| { | ||
| return children; |
There was a problem hiding this comment.
I'd made this node a single child with the ListNode type. imo, it's a bit easier to understand and maintain, but not significantly so.
| bool CrossJoinNode::isEqualImpl(const IQueryTreeNode &, CompareOptions) const { return true; } | ||
| void CrossJoinNode::updateTreeHashImpl(HashState &, CompareOptions) const {} |
There was a problem hiding this comment.
Are hash and isEqual unused for the CrossJoinNode ?
There was a problem hiding this comment.
We recursively check children in the main function.
Btw I forgot to add join types here, will fix.
|
|
||
| QueryTreeNodePtr CrossJoinNode::cloneImpl() const | ||
| { | ||
| return std::make_shared<CrossJoinNode>(children, join_types); |
There was a problem hiding this comment.
Shouldn't we also clone each child?
There was a problem hiding this comment.
Afiak, no, they are copied by the IQueryNode::clone.
| ) | ||
| ENGINE = MergeTree ORDER BY D_DATEKEY; | ||
|
|
||
| EXPLAIN QUERY TREE dump_ast=1 |
There was a problem hiding this comment.
I would just set cross_to_inner_join_rewrite = 2 and verified that the query is executed rather than checking the query tree
There was a problem hiding this comment.
I think it's fine to check the query tree as well,
but I will add the setting as well.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
...
Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):