mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Backport #62811 to 24.3: Fix FINAL modifier is not respected in CTE with analyzer
This commit is contained in:
parent
5e892ea6c9
commit
76a1797147
@ -56,7 +56,9 @@ void IdentifierNode::updateTreeHashImpl(HashState & state, CompareOptions) const
|
||||
|
||||
QueryTreeNodePtr IdentifierNode::cloneImpl() const
|
||||
{
|
||||
return std::make_shared<IdentifierNode>(identifier);
|
||||
auto clone_identifier_node = std::make_shared<IdentifierNode>(identifier);
|
||||
clone_identifier_node->table_expression_modifiers = table_expression_modifiers;
|
||||
return clone_identifier_node;
|
||||
}
|
||||
|
||||
ASTPtr IdentifierNode::toASTImpl(const ConvertToASTOptions & /* options */) const
|
||||
|
24
tests/queries/0_stateless/03129_cte_with_final.reference
Normal file
24
tests/queries/0_stateless/03129_cte_with_final.reference
Normal file
@ -0,0 +1,24 @@
|
||||
QUERY id: 0
|
||||
PROJECTION COLUMNS
|
||||
key Int64
|
||||
someCol String
|
||||
eventTime DateTime
|
||||
PROJECTION
|
||||
LIST id: 1, nodes: 3
|
||||
COLUMN id: 2, column_name: key, result_type: Int64, source_id: 3
|
||||
COLUMN id: 4, column_name: someCol, result_type: String, source_id: 3
|
||||
COLUMN id: 5, column_name: eventTime, result_type: DateTime, source_id: 3
|
||||
JOIN TREE
|
||||
QUERY id: 3, alias: __table1, is_subquery: 1, is_cte: 1, cte_name: merged_test
|
||||
PROJECTION COLUMNS
|
||||
key Int64
|
||||
someCol String
|
||||
eventTime DateTime
|
||||
PROJECTION
|
||||
LIST id: 6, nodes: 3
|
||||
COLUMN id: 7, column_name: key, result_type: Int64, source_id: 8
|
||||
COLUMN id: 9, column_name: someCol, result_type: String, source_id: 8
|
||||
COLUMN id: 10, column_name: eventTime, result_type: DateTime, source_id: 8
|
||||
JOIN TREE
|
||||
TABLE id: 8, alias: __table2, table_name: default.t, final: 1
|
||||
1 first 2024-04-19 01:01:01
|
28
tests/queries/0_stateless/03129_cte_with_final.sql
Normal file
28
tests/queries/0_stateless/03129_cte_with_final.sql
Normal file
@ -0,0 +1,28 @@
|
||||
DROP TABLE IF EXISTS t;
|
||||
|
||||
CREATE TABLE t
|
||||
(
|
||||
`key` Int64,
|
||||
`someCol` String,
|
||||
`eventTime` DateTime
|
||||
)
|
||||
ENGINE = ReplacingMergeTree(eventTime)
|
||||
ORDER BY key;
|
||||
|
||||
INSERT INTO t Values (1, 'first', '2024-04-19 01:01:01');
|
||||
INSERT INTO t Values (1, 'first', '2024-04-19 01:01:01');
|
||||
|
||||
SET allow_experimental_analyzer = 1;
|
||||
|
||||
EXPLAIN QUERY TREE passes=1
|
||||
WITH merged_test AS(
|
||||
SELECT * FROM t Final
|
||||
)
|
||||
SELECT * FROM merged_test;
|
||||
|
||||
WITH merged_test AS(
|
||||
SELECT * FROM t Final
|
||||
)
|
||||
SELECT * FROM merged_test;
|
||||
|
||||
DROP TABLE t;
|
Loading…
Reference in New Issue
Block a user