From debf0e7da4ceede3483690baefe47d106ab122d8 Mon Sep 17 00:00:00 2001 From: Xiangjin Date: Mon, 21 Oct 2024 15:08:27 +0800 Subject: [PATCH] update test expectations --- e2e_test/ddl/alter_rename.slt | 28 ++++++++++++------------ e2e_test/sink/sink_into_table/rename.slt | 8 +++---- src/meta/src/controller/catalog.rs | 4 ++-- src/meta/src/controller/rename.rs | 18 +++++++-------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/e2e_test/ddl/alter_rename.slt b/e2e_test/ddl/alter_rename.slt index 5bae0fe926cac..228ccbefe95b2 100644 --- a/e2e_test/ddl/alter_rename.slt +++ b/e2e_test/ddl/alter_rename.slt @@ -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>) +public.t2 CREATE TABLE "t2" (v1 INT PRIMARY KEY, v2 STRUCT>) 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 @@ -108,7 +108,7 @@ 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; @@ -116,7 +116,7 @@ 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; @@ -124,7 +124,7 @@ 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 @@ -140,12 +140,12 @@ 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; @@ -153,7 +153,7 @@ 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))); @@ -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 @@ -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 diff --git a/e2e_test/sink/sink_into_table/rename.slt b/e2e_test/sink/sink_into_table/rename.slt index f518349c01c27..c9939ef5030eb 100644 --- a/e2e_test/sink/sink_into_table/rename.slt +++ b/e2e_test/sink/sink_into_table/rename.slt @@ -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; @@ -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; diff --git a/src/meta/src/controller/catalog.rs b/src/meta/src/controller/catalog.rs index 5d215344ac0ec..df5c94bc3add5 100644 --- a/src/meta/src/controller/catalog.rs +++ b/src/meta/src/controller/catalog.rs @@ -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', \ @@ -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) diff --git a/src/meta/src/controller/rename.rs b/src/meta/src/controller/rename.rs index 6a924e17c85ad..2301a274c102b 100644 --- a/src/meta/src/controller/rename.rs +++ b/src/meta/src/controller/rename.rs @@ -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); } @@ -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); } @@ -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); } @@ -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); } @@ -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); }