forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ClickHouse#62319 from mxwell/materialized_prim_key
Fix primary key in materialized view
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
tests/queries/0_stateless/03035_materialized_primary_key.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test id | ||
test_mv | ||
test_mv_pk value |
28 changes: 28 additions & 0 deletions
28
tests/queries/0_stateless/03035_materialized_primary_key.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
DROP TABLE IF EXISTS test; | ||
CREATE TABLE test | ||
( | ||
id UInt64, | ||
value String | ||
) ENGINE=MergeTree ORDER BY id; | ||
|
||
INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob'); | ||
|
||
DROP VIEW IF EXISTS test_mv; | ||
CREATE MATERIALIZED VIEW test_mv | ||
( | ||
id UInt64, | ||
value String | ||
) ENGINE=MergeTree | ||
ORDER BY id AS SELECT id, value FROM test; | ||
|
||
DROP VIEW IF EXISTS test_mv_pk; | ||
CREATE MATERIALIZED VIEW test_mv_pk | ||
( | ||
value String, | ||
id UInt64 | ||
) ENGINE=MergeTree PRIMARY KEY value | ||
POPULATE AS SELECT value, id FROM test; | ||
|
||
SELECT name, primary_key | ||
FROM system.tables | ||
WHERE database = currentDatabase() AND name LIKE 'test%'; |