-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop unused columns after join on/using #44545
Conversation
Difference in the query plan (running added test on current version): Details
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Need to fix minor details and merge.
namespace DB | ||
{ | ||
|
||
using ColumnIdentifierSet = std::unordered_set<ColumnIdentifier>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider to move this into TableExpressionData
.
if (node->getNodeType() != QueryTreeNodeType::COLUMN) | ||
return; | ||
|
||
const auto * column_ident = planner_context->getColumnNodeIdentifierOrNull(node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider to rename into column_identifier
.
static bool needChildVisit(VisitQueryTreeNodeType &, VisitQueryTreeNodeType & child) | ||
{ | ||
const auto & node_type = child->getNodeType(); | ||
return node_type != QueryTreeNodeType::TABLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider to remove multiple two spaces after !=
.
|
||
using ColumnIdentifierSet = std::unordered_set<ColumnIdentifier>; | ||
|
||
/// Collect all top level column identifiers from query tree node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider to use /** */
style for multiline comments.
@@ -0,0 +1,22 @@ | |||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to rename this file into CollectColumnIdentifiers.h
from CollectColumnIndetifiers.h
.
|
||
using ColumnIdentifierSet = std::unordered_set<ColumnIdentifier>; | ||
|
||
/// Collect all top level column identifiers from query tree node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add in comment precondition that table expression data must be already collected in planner context.
src/Planner/PlannerJoinTree.h
Outdated
@@ -11,10 +11,13 @@ | |||
namespace DB | |||
{ | |||
|
|||
using ColumnIdentifierSet = std::unordered_set<ColumnIdentifier>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to move this into TableExpressionData
and reuse in CollectColumnIdentifiers
.
|
||
SET allow_experimental_analyzer = 1; | ||
|
||
EXPLAIN PLAN header = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider to enable echoOn
so test will be easier to verify.
76be3b3
to
1b6e036
Compare
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
...