Skip to content

Commit

Permalink
update test expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangjinwu committed Oct 23, 2024
1 parent 3c1e15d commit debf0e7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
28 changes: 14 additions & 14 deletions e2e_test/ddl/alter_rename.slt
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,27 @@ ALTER TABLE t RENAME TO t2;
query TT
SHOW CREATE TABLE t2;
----
public.t2 CREATE TABLE t2 (v1 INT PRIMARY KEY, v2 STRUCT<v1 INT, v2 STRUCT<v1 INT, v2 INT>>)
public.t2 CREATE TABLE "t2" (v1 INT PRIMARY KEY, v2 STRUCT<v1 INT, v2 STRUCT<v1 INT, v2 INT>>)

query TT
SHOW CREATE VIEW v2;
----
public.v2 CREATE VIEW v2 AS (SELECT COUNT(*) FROM t2 AS t, t2 AS t2 WHERE t.v1 = t2.v1)
public.v2 CREATE VIEW v2 AS (SELECT COUNT(*) FROM "t2" AS "t", "t2" AS t2 WHERE t.v1 = t2.v1)

query TT
SHOW CREATE VIEW v3;
----
public.v3 CREATE VIEW v3 AS (SELECT MAX((t.v2).v1) FROM t2 AS t)
public.v3 CREATE VIEW v3 AS (SELECT MAX((t.v2).v1) FROM "t2" AS t)

query TT
SHOW CREATE VIEW v4;
----
public.v4 CREATE VIEW v4 AS (SELECT * FROM t2 AS t JOIN t2 AS t2 ON (t.v1 = t2.v1) ORDER BY t.v1, t2.v1)
public.v4 CREATE VIEW v4 AS (SELECT * FROM "t2" AS "t" JOIN "t2" AS t2 ON (t.v1 = t2.v1) ORDER BY t.v1, t2.v1)

query TT
SHOW CREATE MATERIALIZED VIEW mv;
----
public.mv CREATE MATERIALIZED VIEW mv AS SELECT v1, (t.v2).v1 AS v21 FROM t2 AS t
public.mv CREATE MATERIALIZED VIEW mv AS SELECT v1, (t.v2).v1 AS v21 FROM "t2" AS "t"

# alter mview rename
statement ok
Expand All @@ -108,23 +108,23 @@ ALTER MATERIALIZED VIEW mv RENAME TO mv2;
query TT
SHOW CREATE MATERIALIZED VIEW mv2;
----
public.mv2 CREATE MATERIALIZED VIEW mv2 AS SELECT v1, (t.v2).v1 AS v21 FROM t2 AS t
public.mv2 CREATE MATERIALIZED VIEW "mv2" AS SELECT v1, (t.v2).v1 AS v21 FROM "t2" AS "t"

statement ok
ALTER SINK sink RENAME TO sink1;

query TT
SHOW CREATE SINK sink1;
----
public.sink1 CREATE SINK sink1 AS SELECT mv3.v1 AS v1, mv3.v21 AS v2 FROM mv2 AS mv3 WITH (connector = 'blackhole')
public.sink1 CREATE SINK "sink1" AS SELECT mv3.v1 AS v1, mv3.v21 AS v2 FROM "mv2" AS mv3 WITH (connector = 'blackhole')

statement ok
ALTER SUBSCRIPTION subscription RENAME TO subscription1;

query TT
SHOW CREATE SUBSCRIPTION subscription1;
----
public.subscription1 CREATE SUBSCRIPTION subscription1 FROM mv2 WITH (retention = '1D')
public.subscription1 CREATE SUBSCRIPTION "subscription1" FROM "mv2" WITH (retention = '1D')

# alter mview rename with alias conflict, used by sink1
statement ok
Expand All @@ -140,20 +140,20 @@ ALTER VIEW v1 RENAME TO v5;
query TT
SHOW CREATE VIEW v5;
----
public.v5 CREATE VIEW v5 AS (SELECT * FROM t_as_1 AS t_as WHERE id = 1)
public.v5 CREATE VIEW v5 AS (SELECT * FROM "t_as_1" AS "t_as" WHERE id = 1)

query TT
SHOW CREATE MATERIALIZED VIEW mv_on_v1;
----
public.mv_on_v1 CREATE MATERIALIZED VIEW mv_on_v1 AS SELECT * FROM v5 AS v1
public.mv_on_v1 CREATE MATERIALIZED VIEW mv_on_v1 AS SELECT * FROM "v5" AS "v1"

statement ok
ALTER INDEX idx RENAME TO idx1;

query TT
SHOW CREATE INDEX idx1;
----
public.idx1 CREATE INDEX idx1 ON t2(v1)
public.idx1 CREATE INDEX "idx1" ON "t2"(v1)

statement ok
INSERT INTO t2 VALUES(1,(1,(1,2)));
Expand Down Expand Up @@ -192,12 +192,12 @@ ALTER SOURCE src RENAME TO src1;
query TT
SHOW CREATE SOURCE src1;
----
public.src1 CREATE SOURCE src1 (v INT) WITH (connector = 'datagen', fields.v.kind = 'sequence', fields.v.start = '1', fields.v.end = '10', datagen.rows.per.second = '15', datagen.split.num = '1') FORMAT PLAIN ENCODE JSON
public.src1 CREATE SOURCE "src1" (v INT) WITH (connector = 'datagen', fields.v.kind = 'sequence', fields.v.start = '1', fields.v.end = '10', datagen.rows.per.second = '15', datagen.split.num = '1') FORMAT PLAIN ENCODE JSON

query TT
SHOW CREATE MATERIALIZED VIEW mv4;
----
public.mv4 CREATE MATERIALIZED VIEW mv4 AS SELECT * FROM src1 AS src
public.mv4 CREATE MATERIALIZED VIEW mv4 AS SELECT * FROM "src1" AS "src"

# should use `ALTER TABLE` to alter a table with connector
statement error ALTER TABLE
Expand All @@ -209,7 +209,7 @@ ALTER TABLE msrc RENAME TO msrc1;
query TT
SHOW CREATE TABLE msrc1;
----
public.msrc1 CREATE TABLE msrc1 (v INT) WITH (connector = 'datagen', fields.v.kind = 'sequence', fields.v.start = '1', fields.v.end = '10', datagen.rows.per.second = '15', datagen.split.num = '1') FORMAT PLAIN ENCODE JSON
public.msrc1 CREATE TABLE "msrc1" (v INT) WITH (connector = 'datagen', fields.v.kind = 'sequence', fields.v.start = '1', fields.v.end = '10', datagen.rows.per.second = '15', datagen.split.num = '1') FORMAT PLAIN ENCODE JSON

# the underlying source cannot have the same name with other sources
statement error source .+ exists
Expand Down
8 changes: 4 additions & 4 deletions e2e_test/sink/sink_into_table/rename.slt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ALTER SINK s RENAME TO s1;
query TT
SELECT name, definition from rw_sinks;
----
s1 CREATE SINK s1 INTO target AS SELECT * FROM source WITH (type = 'append-only')
s1 CREATE SINK "s1" INTO target AS SELECT * FROM source WITH (type = 'append-only')

statement ok
ALTER TABLE source RENAME TO src;
Expand All @@ -30,13 +30,13 @@ ALTER TABLE target RENAME TO tar;
query TT rowsort
SELECT name, definition from rw_tables;
----
src CREATE TABLE src (v INT) APPEND ONLY
tar CREATE TABLE tar (v INT)
src CREATE TABLE "src" (v INT) APPEND ONLY
tar CREATE TABLE "tar" (v INT)

query TT
SELECT name, definition from rw_sinks;
----
s1 CREATE SINK s1 INTO tar AS SELECT * FROM src AS source WITH (type = 'append-only')
s1 CREATE SINK "s1" INTO "tar" AS SELECT * FROM "src" AS "source" WITH (type = 'append-only')

statement ok
drop sink s1;
Expand Down
4 changes: 2 additions & 2 deletions src/meta/src/controller/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3681,7 +3681,7 @@ mod tests {
assert_eq!(source.name, "s2");
assert_eq!(
source.definition,
"CREATE SOURCE s2 (v1 INT) WITH (\
"CREATE SOURCE \"s2\" (v1 INT) WITH (\
connector = 'kafka', \
topic = 'kafka_alter', \
properties.bootstrap.server = 'message_queue:29092', \
Expand All @@ -3695,7 +3695,7 @@ mod tests {
.unwrap();
assert_eq!(
view.definition,
"CREATE VIEW view_1 AS SELECT v1 FROM s2 AS s1"
"CREATE VIEW view_1 AS SELECT v1 FROM \"s2\" AS \"s1\""
);

mgr.drop_relation(ObjectType::Source, source_id, DropMode::Cascade)
Expand Down
18 changes: 9 additions & 9 deletions src/meta/src/controller/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ mod tests {
fn test_alter_table_rename() {
let definition = "CREATE TABLE foo (a int, b int)";
let new_name = "bar";
let expected = "CREATE TABLE bar (a INT, b INT)";
let expected = "CREATE TABLE \"bar\" (a INT, b INT)";
let actual = alter_relation_rename(definition, new_name);
assert_eq!(expected, actual);
}
Expand All @@ -468,7 +468,7 @@ mod tests {
let definition = "CREATE INDEX idx1 ON foo(v1 DESC, v2)";
let from = "foo";
let to = "bar";
let expected = "CREATE INDEX idx1 ON bar(v1 DESC, v2)";
let expected = "CREATE INDEX idx1 ON \"bar\"(v1 DESC, v2)";
let actual = alter_relation_rename_refs(definition, from, to);
assert_eq!(expected, actual);
}
Expand All @@ -480,7 +480,7 @@ mod tests {
let from = "foo";
let to = "bar";
let expected =
"CREATE SINK sink_t FROM bar WITH (connector = 'kafka', format = 'append_only')";
"CREATE SINK sink_t FROM \"bar\" WITH (connector = 'kafka', format = 'append_only')";
let actual = alter_relation_rename_refs(definition, from, to);
assert_eq!(expected, actual);
}
Expand All @@ -492,17 +492,17 @@ mod tests {
let from = "foo";
let to = "bar";
let expected =
"CREATE MATERIALIZED VIEW mv1 AS SELECT foo.v1 AS m1v, foo.v2 AS m2v FROM bar AS foo";
"CREATE MATERIALIZED VIEW mv1 AS SELECT foo.v1 AS m1v, foo.v2 AS m2v FROM \"bar\" AS \"foo\"";
let actual = alter_relation_rename_refs(definition, from, to);
assert_eq!(expected, actual);

let definition = "CREATE MATERIALIZED VIEW mv1 AS SELECT foo.v1 AS m1v, (foo.v2).v3 AS m2v FROM foo WHERE foo.v1 = 1 AND (foo.v2).v3 IS TRUE";
let expected = "CREATE MATERIALIZED VIEW mv1 AS SELECT foo.v1 AS m1v, (foo.v2).v3 AS m2v FROM bar AS foo WHERE foo.v1 = 1 AND (foo.v2).v3 IS TRUE";
let expected = "CREATE MATERIALIZED VIEW mv1 AS SELECT foo.v1 AS m1v, (foo.v2).v3 AS m2v FROM \"bar\" AS \"foo\" WHERE foo.v1 = 1 AND (foo.v2).v3 IS TRUE";
let actual = alter_relation_rename_refs(definition, from, to);
assert_eq!(expected, actual);

let definition = "CREATE MATERIALIZED VIEW mv1 AS SELECT bar.v1 AS m1v, (bar.v2).v3 AS m2v FROM foo AS bar WHERE bar.v1 = 1";
let expected = "CREATE MATERIALIZED VIEW mv1 AS SELECT bar.v1 AS m1v, (bar.v2).v3 AS m2v FROM bar AS bar WHERE bar.v1 = 1";
let expected = "CREATE MATERIALIZED VIEW mv1 AS SELECT bar.v1 AS m1v, (bar.v2).v3 AS m2v FROM \"bar\" AS bar WHERE bar.v1 = 1";
let actual = alter_relation_rename_refs(definition, from, to);
assert_eq!(expected, actual);
}
Expand All @@ -523,10 +523,10 @@ mod tests {
agg1(\
foo.v1, func2(foo.v2) \
ORDER BY \
(SELECT foo.v3 FROM bar AS foo), \
(SELECT first_value(foo.v4) OVER (PARTITION BY (SELECT foo.v5 FROM bar AS foo) ORDER BY (SELECT foo.v6 FROM bar AS foo)) FROM bar AS foo)\
(SELECT foo.v3 FROM \"bar\" AS \"foo\"), \
(SELECT first_value(foo.v4) OVER (PARTITION BY (SELECT foo.v5 FROM \"bar\" AS \"foo\") ORDER BY (SELECT foo.v6 FROM \"bar\" AS \"foo\")) FROM \"bar\" AS \"foo\")\
) \
FROM bar AS foo";
FROM \"bar\" AS \"foo\"";
let actual = alter_relation_rename_refs(definition, from, to);
assert_eq!(expected, actual);
}
Expand Down

0 comments on commit debf0e7

Please sign in to comment.