forked from MaterializeInc/materialize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathid.slt
98 lines (75 loc) · 2.01 KB
/
id.slt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
mode cockroach
# Start from a pristine server
reset-server
statement ok
CREATE TABLE x (a int)
statement ok
INSERT INTO x VALUES (1), (2), (3)
query T
SELECT id FROM mz_catalog.mz_tables WHERE name = 'x'
----
u1
query I
SELECT a FROM x
----
1
2
3
query I
SELECT a FROM [u1 AS materialize.public.y]
----
1
2
3
# Renaming the table to something different.
# Referring to it by its "true" name should not work.
statement error column "x.a" does not exist
SELECT x.a FROM [u1 AS materialize.public.y]
# Referring to it by its assigned name should work.
query I
SELECT y.a FROM [u1 AS materialize.public.y]
----
1
2
3
statement error invalid id
SELECT y.a FROM [u6 AS materialize.public.y]
statement error invalid digit
SELECT y.a FROM [xx AS materialize.public.y]
statement ok
CREATE VIEW foo AS SELECT * FROM x
mode standard
# If the name in the catalog matches that which is specified in the view
# definition, we should output it as its (fully qualified) name.
query TT
SHOW CREATE VIEW foo
----
materialize.public.foo
CREATE VIEW "materialize"."public"."foo" AS SELECT * FROM "materialize"."public"."x"
statement ok
DROP VIEW foo;
statement ok
CREATE VIEW foo AS SELECT * FROM [u1 AS materialize.public.x]
query TT
SHOW CREATE VIEW foo
----
materialize.public.foo
CREATE VIEW "materialize"."public"."foo" AS SELECT * FROM "materialize"."public"."x"
# If the name *differs*, fall back to the id version.
statement ok
DROP VIEW foo;
statement ok
CREATE VIEW foo AS SELECT * FROM [u1 AS materialize.public.y]
query TT
SHOW CREATE VIEW foo
----
materialize.public.foo
CREATE VIEW "materialize"."public"."foo" AS SELECT * FROM [u1 AS "materialize"."public"."y"]