123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- # 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 rowsort
- SELECT a FROM x
- ----
- 1
- 2
- 3
- query I rowsort
- 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 rowsort
- 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 couldn't parse id
- SELECT y.a FROM [xx AS materialize.public.y]
- statement error invalid digit
- SELECT y.a FROM [ux 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];
|