Skip to content

Commit

Permalink
Merge branch 'main' into xx/interval
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCroxx authored Nov 20, 2024
2 parents fa99e7b + 3fdd6a5 commit fce4e01
Show file tree
Hide file tree
Showing 73 changed files with 1,705 additions and 836 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ otlp-embedded = { git = "https://github.com/risingwavelabs/otlp-embedded", rev =
prost = { version = "0.13" }
prost-build = { version = "0.13" }
# branch rw_patch
icelake = { git = "https://github.com/risingwavelabs/icelake.git", rev = "68bc9654ea1a1f696b79718b7bcbd79f43488186", features = [
icelake = { git = "https://github.com/risingwavelabs/icelake.git", rev = "0ec44fa826c91139c9cf459b005741df990ae9da", features = [
"prometheus",
] }
# branch dev-rebase-main-20241030
Expand Down
4 changes: 4 additions & 0 deletions ci/scripts/run-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ sqllogictest -p 4566 -d dev './e2e_test/ttl/ttl.slt'
sqllogictest -p 4566 -d dev './e2e_test/database/prepare.slt'
sqllogictest -p 4566 -d test './e2e_test/database/test.slt'

echo "--- e2e, $mode, python_client"
python3 -m pip install --break-system-packages psycopg
python3 ./e2e_test/python_client/main.py

echo "--- e2e, $mode, subscription"
python3 -m pip install --break-system-packages psycopg2-binary
sqllogictest -p 4566 -d dev './e2e_test/subscription/check_sql_statement.slt'
Expand Down
File renamed without changes.
132 changes: 132 additions & 0 deletions e2e_test/batch/basic/dml_update.slt.part
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;
2 changes: 1 addition & 1 deletion e2e_test/batch/distribution_mode.slt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include ./order/*.slt.part
include ./join/*.slt.part
include ./join/*/*.slt.part
include ./aggregate/*.slt.part
include ./types/*.slt.part
include ./types/**/*.slt.part
include ./functions/*.slt.part
include ./over_window/main.slt.part
include ./subquery/**/*.slt.part
Expand Down
2 changes: 1 addition & 1 deletion e2e_test/batch/local_mode.slt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include ./order/*.slt.part
include ./join/*.slt.part
include ./join/*/*.slt.part
include ./aggregate/*.slt.part
include ./types/*.slt.part
include ./types/**/*.slt.part
include ./catalog/*.slt.part
include ./functions/*.slt.part
include ./over_window/main.slt.part
Expand Down
4 changes: 2 additions & 2 deletions e2e_test/batch/types/list/list_case.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SELECT case when i%2=0 then ARRAY[i] else ARRAY[-i] end from (select generate_se
{-3}
{4}

query I
query T
SELECT case when i%2=0 then NULL else ARRAY[i] end from (select generate_series as i from generate_series(0,9,1)) as t;
----
NULL
Expand All @@ -34,7 +34,7 @@ NULL
NULL
{9}

query I
query T
with a as (
SELECT (case when i%2=0 then NULL else ARRAY[i] end) as i from (select generate_series as i from generate_series(0,9,1)) as t
)
Expand Down
34 changes: 17 additions & 17 deletions e2e_test/batch/types/list/list_cast.slt.part
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
statement ok
SET RW_IMPLICIT_FLUSH TO true;

query I
select {1,2,3}::double[];
query T
select array[1,2,3]::double[];
----
{1,2,3}

query I
select {1.4,2.5,3.6}::int[];
query T
select array[1.4,2.5,3.6]::int[];
----
{1,3,4}

query I
select {'1','2','3'}::int[];
query T
select array['1','2','3']::int[];
----
{1,2,3}

statement error
select {'1','2','a'}::int[];
statement error invalid digit
select array['1','2','a']::int[];

query I
select {{1,2.4},{3,4.7},null,{null}::int[]}::int[][];
query T
select array[array[1,2.4],array[3,4.7],null,array[null]::int[]]::int[][];
----
{{1,2},{3,5},NULL,{NULL}}

statement ok
create table t (a double[]);

statement error
insert into t values ({null});
statement error cannot cast
insert into t values (array[null]);

statement ok
insert into t values ({null::double});
insert into t values (array[null::double]);

statement ok
insert into t values ({null}::double[]);
insert into t values (array[null]::double[]);

statement ok
insert into t values (null);

query I
query T
select * from t order by 1;
----
{NULL}
{NULL}
NULL

statement ok
insert into t values ({3.4, 4.3});
insert into t values (array[3.4, 4.3]);

query I
query T
select a::int[] from t order by 1;
----
{3,4}
Expand Down
8 changes: 4 additions & 4 deletions e2e_test/batch/types/list/list_storage.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ CREATE TABLE a(b INTEGER[]);
statement ok
INSERT INTO a VALUES (ARRAY[1, 2]), (NULL), (ARRAY[3, 4, 5, 6]), (ARRAY[NULL, 7]);

query I rowsort
query T rowsort
SELECT * FROM a
----
{1,2}
NULL
{1,2}
{3,4,5,6}
{NULL,7}

Expand All @@ -24,13 +24,13 @@ CREATE TABLE c(b VARCHAR[]);
statement ok
INSERT INTO c VALUES (ARRAY['hello', 'world']), (NULL), (ARRAY['fejwfoaejwfoijwafew', 'b', 'c']), (ARRAY[NULL, 'XXXXXXXXXXXXXXXXXXXXXXXX']);

query I rowsort
query T rowsort
SELECT * FROM c
----
{hello,world}
NULL
{NULL,XXXXXXXXXXXXXXXXXXXXXXXX}
{fejwfoaejwfoijwafew,b,c}
{hello,world}

statement ok
drop table a;
Expand Down
19 changes: 3 additions & 16 deletions e2e_test/batch/types/list/multi-dimentional_list_cast.slt.part
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]];
19 changes: 19 additions & 0 deletions e2e_test/python_client/main.py
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()
6 changes: 0 additions & 6 deletions e2e_test/source_inline/cdc/mysql/mysql_create_drop.slt.serial
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ create source s with (

sleep 2s

# At the beginning, the source is paused. It will resume after a downstream is created.
system ok
internal_table.mjs --name s --type '' --count
----
count: 0


statement ok
create table tt1_shared (v1 int,
Expand Down
Loading

0 comments on commit fce4e01

Please sign in to comment.