You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix issue: #1214
Cloudberry currently only support CTEs with one writable clause,
SELECT INTO caluse with a writable CTE should also be forbidden
as it will create a new table with data inserted.
Authored-by: Zhang Mingli [email protected]
Copy file name to clipboardExpand all lines: src/test/regress/expected/with.out
+25Lines changed: 25 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3239,3 +3239,28 @@ select * from with_test;
3239
3239
(1 row)
3240
3240
3241
3241
drop table with_test;
3242
+
--
3243
+
-- writable CTE with SELECT INTO clause.
3244
+
--
3245
+
CREATE TABLE t_w_cte(a integer);
3246
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Apache Cloudberry data distribution key for this table.
3247
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
3248
+
EXPLAIN(COSTS OFF, VERBOSE) WITH ins AS (
3249
+
INSERT INTO t_w_cte(a) VALUES (1), (2), (3)
3250
+
RETURNING a
3251
+
)
3252
+
SELECT sum(a) INTO t_w_cte_1 FROM ins;
3253
+
ERROR: writable CTE queries cannot be used with writable queries
3254
+
DETAIL: Apache Cloudberry currently only support CTEs with one writable clause, called in a non-writable context.
3255
+
HINT: Rewrite the query to only include one writable clause.
Copy file name to clipboardExpand all lines: src/test/regress/expected/with_optimizer.out
+25Lines changed: 25 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3259,3 +3259,28 @@ select * from with_test;
3259
3259
(1 row)
3260
3260
3261
3261
drop table with_test;
3262
+
--
3263
+
-- writable CTE with SELECT INTO clause.
3264
+
--
3265
+
CREATE TABLE t_w_cte(a integer);
3266
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Apache Cloudberry data distribution key for this table.
3267
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
3268
+
EXPLAIN(COSTS OFF, VERBOSE) WITH ins AS (
3269
+
INSERT INTO t_w_cte(a) VALUES (1), (2), (3)
3270
+
RETURNING a
3271
+
)
3272
+
SELECT sum(a) INTO t_w_cte_1 FROM ins;
3273
+
ERROR: writable CTE queries cannot be used with writable queries
3274
+
DETAIL: Apache Cloudberry currently only support CTEs with one writable clause, called in a non-writable context.
3275
+
HINT: Rewrite the query to only include one writable clause.
0 commit comments