mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fixed test [#CLICKHOUSE-2].
This commit is contained in:
parent
de1f4f4c5b
commit
3dcb2e6aed
@ -1721,18 +1721,18 @@ public:
|
||||
|
||||
if (cond_col)
|
||||
{
|
||||
if (!( executeLeftType<UInt8>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<UInt16>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<UInt32>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<UInt64>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Int8>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Int16>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Int32>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Int64>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Float32>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Float64>(cond_col, block, arguments, result)
|
||||
|| executeString(cond_col, block, arguments, result)
|
||||
|| executeTuple(cond_col, block, arguments, result)))
|
||||
if (!( executeLeftType<UInt8>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<UInt16>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<UInt32>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<UInt64>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Int8>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Int16>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Int32>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Int64>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Float32>(cond_col, block, arguments, result)
|
||||
|| executeLeftType<Float64>(cond_col, block, arguments, result)
|
||||
|| executeString(cond_col, block, arguments, result)
|
||||
|| executeTuple(cond_col, block, arguments, result)))
|
||||
throw Exception("Illegal columns " + arg_then.column->getName()
|
||||
+ " and " + arg_else.column->getName()
|
||||
+ " of second (then) and third (else) arguments of function " + getName(),
|
||||
|
@ -929,6 +929,27 @@ void ExpressionAnalyzer::addASTAliases(ASTPtr & ast, int ignore_levels)
|
||||
|
||||
aliases[alias] = ast;
|
||||
}
|
||||
else if (typeid_cast<ASTSubquery *>(ast.get()))
|
||||
{
|
||||
/// Set unique aliases for all subqueries. This is needed, because content of subqueries could change after recursive analysis,
|
||||
/// and auto-generated column names could become incorrect.
|
||||
|
||||
size_t subquery_index = 1;
|
||||
while (true)
|
||||
{
|
||||
alias = "_subquery" + toString(subquery_index);
|
||||
if (!aliases.count("_subquery" + toString(subquery_index)))
|
||||
break;
|
||||
++subquery_index;
|
||||
}
|
||||
|
||||
std::cerr << ast->getColumnName() << "\n";
|
||||
|
||||
ast->setAlias(alias);
|
||||
aliases[alias] = ast;
|
||||
|
||||
std::cerr << ast->getAliasOrColumnName() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
13
dbms/src/Parsers/ASTSubquery.cpp
Normal file
13
dbms/src/Parsers/ASTSubquery.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include <Parsers/ASTSubquery.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
String ASTSubquery::getColumnName() const
|
||||
{
|
||||
/// This is a hack. We use alias, if available, because otherwise tree could change during analysis.
|
||||
return alias.empty() ? getTreeID() : alias;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
return ptr;
|
||||
}
|
||||
|
||||
String getColumnName() const override { return getTreeID(); }
|
||||
String getColumnName() const override;
|
||||
|
||||
protected:
|
||||
void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
||||
|
@ -17,9 +17,9 @@ public:
|
||||
|
||||
using IAST::IAST;
|
||||
|
||||
String getAliasOrColumnName() const override { return alias.empty() ? getColumnName() : alias; }
|
||||
String tryGetAlias() const override { return alias; }
|
||||
void setAlias(const String & to) override { alias = to; }
|
||||
String getAliasOrColumnName() const override { return alias.empty() ? getColumnName() : alias; }
|
||||
String tryGetAlias() const override { return alias; }
|
||||
void setAlias(const String & to) override { alias = to; }
|
||||
|
||||
/// Calls formatImplWithoutAlias, and also outputs an alias. If necessary, encloses the entire expression in brackets.
|
||||
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override final;
|
||||
|
@ -0,0 +1,4 @@
|
||||
1
|
||||
3
|
||||
4
|
||||
5
|
@ -0,0 +1,5 @@
|
||||
SELECT 1 FROM system.one WHERE (1, 1) IN (SELECT 1 AS x, x);
|
||||
SELECT 2 FROM system.one WHERE (1, 1) IN (SELECT 1 AS x, x) AND (1, 0) IN (SELECT 1 AS x, x);
|
||||
SELECT 3 FROM system.one WHERE (1, 1) IN (SELECT 1 AS x, x) OR (1, 0) IN (SELECT 1 AS x, x);
|
||||
SELECT 4 FROM system.one WHERE (1, 1) IN (SELECT 1 AS x, x) AND (1, 0) IN (SELECT 1 AS x, toUInt8(x - 1));
|
||||
SELECT 5 FROM system.one WHERE (1, 1) IN (SELECT 1 AS x, x) OR (1, 0) IN (SELECT 1 AS x, toUInt8(x - 1));
|
Loading…
Reference in New Issue
Block a user