Skip to content

Commit

Permalink
Merge pull request #63767 from ClickHouse/cherrypick/24.2/7de852fccc9…
Browse files Browse the repository at this point in the history
…cada42173444b892511a37d038aea

Cherry pick #63694 to 24.2: Analyzer: Forbid WINDOW redefinition
  • Loading branch information
robot-clickhouse-ci-1 committed May 14, 2024
2 parents 7bf8f04 + 7de852f commit 056c6f3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Analyzer/Passes/QueryAnalysisPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7540,7 +7540,12 @@ void QueryAnalyzer::resolveQuery(const QueryTreeNodePtr & query_node, Identifier
window_node_typed.setParentWindowName({});
}

scope.window_name_to_window_node.emplace(window_node_typed.getAlias(), window_node);
auto [_, inserted] = scope.window_name_to_window_node.emplace(window_node_typed.getAlias(), window_node);
if (!inserted)
throw Exception(ErrorCodes::BAD_ARGUMENTS,
"Window '{}' is already defined. In scope {}",
window_node_typed.getAlias(),
scope.scope_node->formatASTForErrorMessage());
}

/** Disable identifier cache during JOIN TREE resolve.
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE users (uid Int16, name String, age Int16) ENGINE=MergeTree ORDER BY tuple();

INSERT INTO users VALUES (1231, 'John', 33);
INSERT INTO users VALUES (6666, 'Ksenia', 48);
INSERT INTO users VALUES (8888, 'Alice', 50);

SELECT count(*) OVER w
FROM users WINDOW w AS (ORDER BY uid), w AS(ORDER BY name); -- { serverError BAD_ARGUMENTS }

0 comments on commit 056c6f3

Please sign in to comment.