forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 1
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#70593 from jsc0218/InsertWith
With Insert Support
- Loading branch information
Showing
6 changed files
with
114 additions
and
1 deletion.
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
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
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,20 @@ | ||
0 | ||
1 | ||
2 | ||
3 | ||
4 | ||
0 | ||
1 | ||
2 | ||
3 | ||
4 | ||
2025-01-01 | ||
2026-01-01 | ||
2027-01-01 | ||
2028-01-01 | ||
2029-01-01 | ||
2030-01-01 | ||
2031-01-01 | ||
2032-01-01 | ||
2033-01-01 | ||
2034-01-01 |
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,49 @@ | ||
DROP TABLE IF EXISTS x; | ||
|
||
CREATE TABLE x ENGINE = Log AS SELECT * FROM numbers(0); | ||
|
||
SYSTEM STOP MERGES x; | ||
|
||
WITH y AS | ||
( | ||
SELECT * | ||
FROM numbers(10) | ||
) | ||
INSERT INTO x | ||
SELECT * | ||
FROM y | ||
INTERSECT | ||
SELECT * | ||
FROM numbers(5); | ||
|
||
WITH y AS | ||
( | ||
SELECT * | ||
FROM numbers(10) | ||
) | ||
INSERT INTO x | ||
SELECT * | ||
FROM numbers(5) | ||
INTERSECT | ||
SELECT * | ||
FROM y; | ||
|
||
SELECT * FROM x; | ||
|
||
DROP TABLE x; | ||
|
||
CREATE TABLE x (d date) ENGINE = Log; | ||
|
||
WITH y AS | ||
( | ||
SELECT | ||
number, | ||
date_add(YEAR, number, toDate('2025-01-01')) AS new_date | ||
FROM numbers(10) | ||
) | ||
INSERT INTO x | ||
SELECT y.new_date FROM y; | ||
|
||
SELECT * FROM x; | ||
|
||
DROP TABLE x; |
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 @@ | ||
Only one WITH should be presented, either before INSERT or SELECT |
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,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
# shellcheck source=../shell_config.sh | ||
. "$CUR_DIR"/../shell_config.sh | ||
|
||
$CLICKHOUSE_CLIENT -q 'DROP TABLE IF EXISTS x' | ||
$CLICKHOUSE_CLIENT -q 'CREATE TABLE x ENGINE = Log AS SELECT * FROM numbers(0)' | ||
$CLICKHOUSE_CLIENT -q 'WITH y AS ( SELECT * FROM numbers(10) ) INSERT INTO x WITH y2 AS ( SELECT * FROM numbers(10) ) SELECT * FROM y;' |& grep --max-count 1 -F --only-matching "Only one WITH should be presented, either before INSERT or SELECT" | ||
$CLICKHOUSE_CLIENT -q 'DROP TABLE x' |