mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 20:02:05 +00:00
Fix
This commit is contained in:
parent
4ff612f2c3
commit
62153e7030
@ -137,20 +137,10 @@ static bool needVisitChild(const ASTPtr & child)
|
||||
void QueryNormalizer::visit(ASTSelectQuery & select, const ASTPtr &, Data & data)
|
||||
{
|
||||
for (auto & child : select.children)
|
||||
{
|
||||
if (child == select.groupBy() || child == select.orderBy() || child == select.having())
|
||||
{
|
||||
bool old_setting = data.settings.prefer_column_name_to_alias;
|
||||
data.settings.prefer_column_name_to_alias = false;
|
||||
visit(child, data);
|
||||
data.settings.prefer_column_name_to_alias = old_setting;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (needVisitChild(child))
|
||||
visit(child, data);
|
||||
}
|
||||
}
|
||||
|
||||
/// If the WHERE clause or HAVING consists of a single alias, the reference must be replaced not only in children,
|
||||
/// but also in where_expression and having_expression.
|
||||
|
@ -1,3 +1,5 @@
|
||||
4.5 9
|
||||
3 2
|
||||
3 3
|
||||
3 1 1 2
|
||||
3 1 1 2
|
||||
|
@ -6,3 +6,13 @@ set prefer_column_name_to_alias = 1;
|
||||
SELECT avg(number) AS number, max(number) FROM numbers(10);
|
||||
SELECT sum(x) AS x, max(x) FROM (SELECT 1 AS x UNION ALL SELECT 2 AS x) t settings prefer_column_name_to_alias = 1;
|
||||
select sum(C1) as C1, count(C1) as C2 from (select number as C1 from numbers(3)) as ITBL settings prefer_column_name_to_alias = 1;
|
||||
|
||||
DROP TABLE IF EXISTS mytable;
|
||||
CREATE TABLE IF NOT EXISTS mytable (start_ts UInt32, end_ts UInt32, uuid String) ENGINE = MergeTree() ORDER BY start_ts;
|
||||
INSERT INTO mytable VALUES (1, 2, 3);
|
||||
|
||||
SELECT any(uuid) AS id, max(end_ts) - any(start_ts) AS time_delta, any(start_ts) AS start_ts, max(end_ts) AS end_ts FROM mytable GROUP BY uuid HAVING max(end_ts) < 1620141001 ORDER BY any(start_ts) DESC;
|
||||
|
||||
SELECT any(uuid) AS id, max(end_ts) - any(start_ts) AS time_delta, any(start_ts) AS start_ts, max(end_ts) AS end_ts FROM mytable GROUP BY uuid HAVING max(end_ts) < 1620141001 ORDER BY any(start_ts) DESC SETTINGS prefer_column_name_to_alias=1;
|
||||
|
||||
DROP TABLE mytable;
|
||||
|
Loading…
Reference in New Issue
Block a user