-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Improve push-down logic for joined statements #4387
Conversation
f3c84ac
to
1344ff6
Compare
|
||
-- Optimize predicate expression with view | ||
-- TODO: simple view is not replaced with subquery inside syntax analyzer | ||
ANALYZE SELECT * FROM test.test_view WHERE id = 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.
Maybe the same as #4387 (comment) ?
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.
No, it's not the same - at least from the SyntaxAnalyzer
point of view.
1344ff6
to
bc5e75e
Compare
ANALYZE SELECT id FROM test.test_view WHERE id = 1; | ||
ANALYZE SELECT s.id FROM test.test_view AS s WHERE s.id = 1; | ||
|
||
-- TODO: this query shouldn't work, because the name `toUInt64(sum(id))` is undefined for user |
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.
I'm going to fix this. Maybe SELECT * FROM (SELECT toUInt64(b), sum(id) AS b FROM test.test) WHERE `toUInt64(b)` = 3;
should work ?
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.
No, the problem is the opposite: it works now, but it shouldn't, because we somehow allow users to exploit internal aliases. This should be fixed by hiding internal aliases from user. Potentially, we can change internal alias naming scheme any time and such queries will become invalid.
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.
The alias is actually added for support SELECT * FROM (SELECT 1) WHERE `1` = 1
, it works without predicate optimization. original pull request: #3107
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.
Oh, yes, it's not related to the push-down - it's a standalone issue. I discussed it with @alexey-milovidov already.
that prints out the query after syntax analysis. Should be helpful for tests.
to support push-down while analyzing.
ed09087
to
09af551
Compare
@@ -594,8 +596,28 @@ Names qualifyOccupiedNames(NamesAndTypesList & columns, const NameSet & source_c | |||
return originals; | |||
} | |||
|
|||
void replaceJoinedTable(const ASTTablesInSelectQueryElement* join) |
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.
👍
Also implement the debug query "ANALYZE", which prints out the query after syntax analysis. Should be helpful for tests.
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en