Merge pull request #2064 from yandex/sets-with-aliases

Sets for IN operator could be used via alias
This commit is contained in:
alexey-milovidov 2018-03-15 22:07:49 +03:00 committed by GitHub
commit 26ca895c0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 1 deletions

View File

@ -980,7 +980,8 @@ void ExpressionAnalyzer::normalizeTreeImpl(
/// `IN t` can be specified, where t is a table, which is equivalent to `IN (SELECT * FROM t)`.
if (functionIsInOrGlobalInOperator(func_node->name))
if (ASTIdentifier * right = typeid_cast<ASTIdentifier *>(func_node->arguments->children.at(1).get()))
right->kind = ASTIdentifier::Table;
if (!aliases.count(right->name))
right->kind = ASTIdentifier::Table;
/// Special cases for count function.
String func_name_lowercase = Poco::toLower(func_node->name);

View File

@ -4,3 +4,4 @@ SELECT toDate('2015-06-12') IN (toDate('2015-06-12'));
SELECT today() IN (toDate('2014-01-01'), toDate(now()));
SELECT - -1 IN (2 - 1);
SELECT - -1 IN (2 - 1, 3);
WITH (1, 2) AS a SELECT 1 IN a, 3 IN a;