mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
fix lambda function in predicate
This commit is contained in:
parent
6d3e56def4
commit
2179935f1e
@ -2,6 +2,7 @@
|
||||
#include <Functions/FunctionFactory.h>
|
||||
#include <AggregateFunctions/AggregateFunctionFactory.h>
|
||||
#include <Interpreters/IdentifierSemantic.h>
|
||||
#include <Parsers/ASTSubquery.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -55,6 +56,11 @@ void ExpressionInfoMatcher::visit(const ASTIdentifier & identifier, const ASTPtr
|
||||
}
|
||||
}
|
||||
|
||||
bool ExpressionInfoMatcher::needChildVisit(const ASTPtr & node, const ASTPtr &)
|
||||
{
|
||||
return !node->as<ASTSubquery>();
|
||||
}
|
||||
|
||||
bool hasStatefulFunction(const ASTPtr & node, const Context & context)
|
||||
{
|
||||
for (const auto & select_expression : node->children)
|
||||
|
@ -26,7 +26,7 @@ struct ExpressionInfoMatcher
|
||||
|
||||
static void visit(const ASTPtr & ast, Data & data);
|
||||
|
||||
static bool needChildVisit(const ASTPtr &, const ASTPtr &) { return true; }
|
||||
static bool needChildVisit(const ASTPtr & node, const ASTPtr &);
|
||||
|
||||
static void visit(const ASTFunction & ast_function, const ASTPtr &, Data & data);
|
||||
|
||||
|
@ -101,11 +101,12 @@ bool PredicateRewriteVisitorData::rewriteSubquery(ASTSelectQuery & subquery, con
|
||||
const auto & column_name = identifiers[index]->shortName();
|
||||
const auto & outer_column_iterator = std::find(outer_columns.begin(), outer_columns.end(), column_name);
|
||||
|
||||
if (outer_column_iterator == outer_columns.end())
|
||||
throw Exception("LOGICAL ERROR: the column " + column_name + " does not exists.", ErrorCodes::LOGICAL_ERROR);
|
||||
|
||||
if (outer_column_iterator != outer_columns.end())
|
||||
{
|
||||
/// Some temporary identifiers may be included in the predicate, for example: WHERE arrayMap(x -> x, [column_a]) = [column_a]
|
||||
identifiers[index]->setShortName(inner_columns[outer_column_iterator - outer_columns.begin()]);
|
||||
}
|
||||
}
|
||||
|
||||
/// We only need to push all the predicates to subquery having
|
||||
/// The subquery optimizer will move the appropriate predicates from having to where
|
||||
|
@ -24,3 +24,5 @@ SELECT \n ts AS `--a.ts`, \n id AS `--a.id`, \n id_b AS `--a.id_b`, \n
|
||||
4 0
|
||||
2 3
|
||||
4 5
|
||||
SELECT dummy\nFROM \n(\n SELECT dummy\n FROM system.one\n WHERE arrayMap(x -> (x + 1), [dummy]) = [1]\n)\nWHERE arrayMap(x -> (x + 1), [dummy]) = [1]
|
||||
0
|
||||
|
@ -71,4 +71,6 @@ SELECT B, next_B FROM (SELECT A, B, neighbor(B, 1) AS next_B FROM (SELECT * FROM
|
||||
|
||||
DROP TABLE IF EXISTS test;
|
||||
|
||||
ANALYZE SELECT * FROM (SELECT * FROM system.one) WHERE arrayMap(x -> x + 1, [dummy]) = [1];
|
||||
SELECT * FROM (SELECT * FROM system.one) WHERE arrayMap(x -> x + 1, [dummy]) = [1];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user