mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
add tests and fix build
This commit is contained in:
parent
bd01bdad97
commit
af2b17fbcb
@ -48,7 +48,7 @@ ASTs OptimizeIfChainsVisitor::IfChain(ASTPtr & child)
|
||||
throw Exception("Wrong number of arguments for function 'if' (" + toString(args->children.size()) + " instead of 3)",
|
||||
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
||||
|
||||
if (args->children[2]->as<ASTFunction>() && args->children[2]->as<ASTFunction>()->name == "if" )
|
||||
if (args->children[2]->as<ASTFunction>() && args->children[2]->as<ASTFunction>()->name == "if")
|
||||
{
|
||||
auto cur = IfChain(function_node->arguments->children[2]);
|
||||
cur.push_back(function_node->arguments->children[1]);
|
||||
|
@ -9,16 +9,12 @@ namespace DB
|
||||
class OptimizeIfChainsVisitor
|
||||
{
|
||||
public:
|
||||
OptimizeIfChainsVisitor(Aliases & aliases_)
|
||||
: aliases(aliases_)
|
||||
{}
|
||||
OptimizeIfChainsVisitor() = default;
|
||||
|
||||
void visit(ASTPtr & ast);
|
||||
|
||||
ASTs IfChain(ASTPtr & child);
|
||||
|
||||
private:
|
||||
Aliases & aliases;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -915,7 +915,7 @@ SyntaxAnalyzerResultPtr SyntaxAnalyzer::analyze(
|
||||
/// Optimize if with constant condition after constants was substituted instead of scalar subqueries.
|
||||
OptimizeIfWithConstantConditionVisitor(result.aliases).visit(query);
|
||||
|
||||
OptimizeIfChainsVisitor(result.aliases).visit(query);
|
||||
OptimizeIfChainsVisitor().visit(query);
|
||||
|
||||
if (select_query)
|
||||
{
|
||||
|
2002
dbms/tests/queries/0_stateless/01053_if_chain_check.reference
Normal file
2002
dbms/tests/queries/0_stateless/01053_if_chain_check.reference
Normal file
File diff suppressed because it is too large
Load Diff
3
dbms/tests/queries/0_stateless/01053_if_chain_check.sql
Normal file
3
dbms/tests/queries/0_stateless/01053_if_chain_check.sql
Normal file
@ -0,0 +1,3 @@
|
||||
SELECT x FROM (SELECT number % 16 = 0 ? nan : (number % 24 = 0 ? NULL : (number % 37 = 0 ? nan : (number % 34 = 0 ? nan : (number % 3 = 0 ? NULL : (number % 68 = 0 ? 42 : (number % 28 = 0 ? nan : (number % 46 = 0 ? nan : (number % 13 = 0 ? nan : (number % 27 = 0 ? NULL : (number % 39 = 0 ? NULL : (number % 27 = 0 ? NULL : (number % 30 = 0 ? NULL : (number % 72 = 0 ? NULL : (number % 36 = 0 ? NULL : (number % 51 = 0 ? NULL : (number % 58 = 0 ? nan : (number % 26 = 0 ? 42 : (number % 13 = 0 ? nan : (number % 12 = 0 ? NULL : (number % 22 = 0 ? nan : (number % 36 = 0 ? NULL : (number % 63 = 0 ? NULL : (number % 27 = 0 ? NULL : (number % 18 = 0 ? NULL : (number % 69 = 0 ? NULL : (number % 76 = 0 ? nan : (number % 42 = 0 ? NULL : (number % 9 = 0 ? NULL : (toFloat64(number)))))))))))))))))))))))))))))) AS x FROM system.numbers LIMIT 1001) ORDER BY x ASC NULLS FIRST;
|
||||
|
||||
SELECT x FROM (SELECT number % 22 = 0 ? nan : (number % 56 = 0 ? 42 : (number % 45 = 0 ? NULL : (number % 47 = 0 ? 42 : (number % 39 = 0 ? NULL : (number % 1 = 0 ? nan : (number % 43 = 0 ? nan : (number % 40 = 0 ? nan : (number % 42 = 0 ? NULL : (number % 26 = 0 ? 42 : (number % 41 = 0 ? 42 : (number % 6 = 0 ? NULL : (number % 39 = 0 ? NULL : (number % 34 = 0 ? nan : (number % 74 = 0 ? 42 : (number % 40 = 0 ? nan : (number % 37 = 0 ? nan : (number % 51 = 0 ? NULL : (number % 46 = 0 ? nan : (toFloat64(number)))))))))))))))))))) AS x FROM system.numbers LIMIT 1001) ORDER BY x ASC NULLS FIRST;
|
Loading…
Reference in New Issue
Block a user