create-views.td 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. #
  10. # General CREATE VIEW testing
  11. #
  12. > CREATE TABLE t (a INT, b INT);
  13. > INSERT INTO t VALUES (1, 2);
  14. ! CREATE VIEW t_v AS SELECT a, a FROM t;
  15. contains:column "a" specified more than once
  16. ! CREATE VIEW t_v AS SELECT b, a, b FROM t;
  17. contains:column "b" specified more than once
  18. ! CREATE VIEW t_v AS SELECT a, b AS a FROM t;
  19. contains:column "a" specified more than once
  20. ! CREATE VIEW t_v AS SELECT a, b FROM t AS t(a, a);
  21. contains:column reference "a" is ambiguous
  22. > CREATE VIEW t_v AS SELECT a, b FROM t;
  23. > SELECT * FROM t_v;
  24. 1 2
  25. > CREATE VIEW t_v_alias AS SELECT a, b FROM t AS t (b, a);
  26. > SELECT * FROM t_v_alias
  27. 2 1
  28. ! CREATE MATERIALIZED VIEW t_m_v AS SELECT a, a FROM t;
  29. contains:column "a" specified more than once
  30. ! CREATE MATERIALIZED VIEW t_m_v AS SELECT b, a, b FROM t;
  31. contains:column "b" specified more than once
  32. ! CREATE MATERIALIZED VIEW t_m_v AS SELECT a, b AS a FROM t;
  33. contains:column "a" specified more than once
  34. ! CREATE MATERIALIZED VIEW t_m_v AS SELECT a, b FROM t AS t(a, a);
  35. contains:column reference "a" is ambiguous
  36. > CREATE MATERIALIZED VIEW t_m_v AS SELECT a, b FROM t;
  37. > SELECT * FROM t_v;
  38. 1 2
  39. > CREATE MATERIALIZED VIEW t_m_v_alias AS SELECT a, b FROM t AS t (b, a);
  40. > SELECT * FROM t_v_alias
  41. 2 1
  42. # Regression for database-issues#2869
  43. ! CREATE VIEW gh9376 AS SELECT 1, 2;
  44. contains:column "?column?" specified more than once
  45. >CREATE VIEW gh9376 AS SELECT 1;
  46. > SELECT name FROM mz_columns WHERE id = (SELECT id FROM mz_views WHERE name = 'gh9376');
  47. \?column?