-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into xx/interval
- Loading branch information
Showing
73 changed files
with
1,705 additions
and
836 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
File renamed without changes.
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,132 @@ | ||
# Extension to `dml_basic.slt.part` for testing advanced `UPDATE` statements. | ||
|
||
statement ok | ||
SET RW_IMPLICIT_FLUSH TO true; | ||
|
||
statement ok | ||
create table t (v1 int default 1919, v2 int default 810); | ||
|
||
statement ok | ||
insert into t values (114, 514); | ||
|
||
|
||
# Single assignment, to subquery. | ||
statement ok | ||
update t set v1 = (select 666); | ||
|
||
query II | ||
select * from t; | ||
---- | ||
666 514 | ||
|
||
# Single assignment, to runtime-cardinality subquery returning 1 row. | ||
statement ok | ||
update t set v1 = (select generate_series(888, 888)); | ||
|
||
query II | ||
select * from t; | ||
---- | ||
888 514 | ||
|
||
# Single assignment, to runtime-cardinality subquery returning 0 rows (set to NULL). | ||
statement ok | ||
update t set v1 = (select generate_series(1, 0)); | ||
|
||
query II | ||
select * from t; | ||
---- | ||
NULL 514 | ||
|
||
# Single assignment, to runtime-cardinality subquery returning multiple rows. | ||
statement error Scalar subquery produced more than one row | ||
update t set v1 = (select generate_series(1, 2)); | ||
|
||
# Single assignment, to correlated subquery. | ||
statement ok | ||
update t set v1 = (select count(*) from t as source where source.v2 = t.v2); | ||
|
||
query II | ||
select * from t; | ||
---- | ||
1 514 | ||
|
||
# Single assignment, to subquery with mismatched column count. | ||
statement error must return only one column | ||
update t set v1 = (select 666, 888); | ||
|
||
|
||
# Multiple assignment clauses. | ||
statement ok | ||
update t set v1 = 1919, v2 = 810; | ||
|
||
query II | ||
select * from t; | ||
---- | ||
1919 810 | ||
|
||
# Multiple assignments to the same column. | ||
statement error multiple assignments to the same column | ||
update t set v1 = 1, v1 = 2; | ||
|
||
statement error multiple assignments to the same column | ||
update t set (v1, v1) = (1, 2); | ||
|
||
statement error multiple assignments to the same column | ||
update t set (v1, v2) = (1, 2), v2 = 2; | ||
|
||
# Multiple assignments, to subquery. | ||
statement ok | ||
update t set (v1, v2) = (select 666, 888); | ||
|
||
query II | ||
select * from t; | ||
---- | ||
666 888 | ||
|
||
# Multiple assignments, to subquery with cast. | ||
statement ok | ||
update t set (v1, v2) = (select 888.88, 999); | ||
|
||
query II | ||
select * from t; | ||
---- | ||
889 999 | ||
|
||
# Multiple assignments, to subquery with cast failure. | ||
# TODO: this currently shows `cannot cast type "record" to "record"` because we wrap the subquery result | ||
# into a struct, which is not quite clear. | ||
statement error cannot cast type | ||
update t set (v1, v2) = (select '888.88', 999); | ||
|
||
# Multiple assignments, to subquery with mismatched column count. | ||
statement error number of columns does not match number of values | ||
update t set (v1, v2) = (select 666); | ||
|
||
# Multiple assignments, to scalar expression. | ||
statement error source for a multiple-column UPDATE item must be a sub-SELECT or ROW\(\) expression | ||
update t set (v1, v2) = v1 + 1; | ||
|
||
|
||
# Assignment to system columns. | ||
statement error update modifying column `_rw_timestamp` is unsupported | ||
update t set _rw_timestamp = _rw_timestamp + interval '1 second'; | ||
|
||
|
||
# https://github.com/risingwavelabs/risingwave/pull/19402#pullrequestreview-2444427475 | ||
# https://github.com/risingwavelabs/risingwave/pull/19452 | ||
statement ok | ||
create table y (v1 int, v2 int); | ||
|
||
statement ok | ||
insert into y values (11, 11), (22, 22); | ||
|
||
statement error Scalar subquery produced more than one row | ||
update t set (v1, v2) = (select y.v1, y.v2 from y); | ||
|
||
statement ok | ||
drop table y; | ||
|
||
|
||
# Cleanup. | ||
statement ok | ||
drop table t; |
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
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
19 changes: 3 additions & 16 deletions
19
e2e_test/batch/types/list/multi-dimentional_list_cast.slt.part
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 |
---|---|---|
@@ -1,25 +1,12 @@ | ||
query I | ||
query T | ||
select array[array[1, 2], array[3, 4]]; | ||
---- | ||
{{1,2},{3,4}} | ||
|
||
query I | ||
query T | ||
select array[[1, 2], [3, 4]]; | ||
---- | ||
{{1,2},{3,4}} | ||
|
||
query I | ||
query error sql parser error | ||
select array[[array[1, 2]], [[3, 4]]]; | ||
---- | ||
{{{1,2}},{{3,4}}} | ||
|
||
query I | ||
select array[[[1, 2]], [array[3, 4]]]; | ||
---- | ||
{{{1,2}},{{3,4}}} | ||
|
||
statement error syntax error at or near | ||
select array[array[1, 2], [3, 4]]; | ||
|
||
statement error syntax error at or near | ||
select array[[1, 2], array[3, 4]]; |
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,19 @@ | ||
import psycopg | ||
|
||
def test_psycopg_extended_mode(): | ||
conn = psycopg.connect(host='localhost', port='4566', dbname='dev', user='root') | ||
with conn.cursor() as cur: | ||
cur.execute("select Array[1::bigint, 2::bigint, 3::bigint]", binary=True) | ||
assert cur.fetchone() == ([1, 2, 3],) | ||
|
||
cur.execute("select Array['foo', null, 'bar']", binary=True) | ||
assert cur.fetchone() == (['foo', None, 'bar'],) | ||
|
||
cur.execute("select ROW('123 Main St', 'New York', '10001')", binary=True) | ||
assert cur.fetchone() == (('123 Main St', 'New York', '10001'),) | ||
|
||
cur.execute("select array[ROW('123 Main St', 'New York', '10001'), ROW('234 Main St', null, '10001')]", binary=True) | ||
assert cur.fetchone() == ([('123 Main St', 'New York', '10001'), ('234 Main St', None, '10001')],) | ||
|
||
if __name__ == '__main__': | ||
test_psycopg_extended_mode() |
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
Oops, something went wrong.