partition-by.td 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. $ set-arg-default single-replica-cluster=quickstart
  10. # Tests for the new PARTITION BY syntax for persisted collections.
  11. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  12. ALTER SYSTEM SET enable_create_table_from_source = true
  13. > CREATE SOURCE auction_house
  14. IN CLUSTER ${arg.single-replica-cluster}
  15. FROM LOAD GENERATOR AUCTION
  16. FOR TABLES (accounts);
  17. # First, check that disabling the flag works.
  18. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  19. ALTER SYSTEM SET enable_collection_partition_by = false
  20. ! CREATE MATERIALIZED VIEW integers (n) WITH (PARTITION BY (n)) AS VALUES (3), (2), (1);
  21. contains:PARTITION BY
  22. ! CREATE TABLE integers (n int) WITH (PARTITION BY (n));
  23. contains:PARTITION BY
  24. ! CREATE TABLE bids FROM SOURCE auction_house (REFERENCE bids) WITH (PARTITION BY (id));
  25. contains:PARTITION BY
  26. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  27. ALTER SYSTEM SET enable_collection_partition_by = true
  28. > CREATE MATERIALIZED VIEW integers (n) WITH (PARTITION BY (n)) AS VALUES (3), (2), (1);
  29. > CREATE MATERIALIZED VIEW integers_strings (n, m) WITH (PARTITION BY (n, m))
  30. AS VALUES (3, 'three'), (2, 'two'), (1, 'one');
  31. ! CREATE MATERIALIZED VIEW out_of_order (n, m) WITH (PARTITION BY (m, n))
  32. AS VALUES (3, 'three'), (2, 'two'), (1, 'one');
  33. contains:PARTITION BY columns should be a prefix
  34. ! CREATE MATERIALIZED VIEW out_of_order (n, m) WITH (PARTITION BY (m))
  35. AS VALUES (3, 'three'), (2, 'two'), (1, 'one');
  36. contains:PARTITION BY columns should be a prefix
  37. ! CREATE MATERIALIZED VIEW unsupported_type (n, m) WITH (PARTITION BY (n, m))
  38. AS VALUES (3, '[3]'::json), (2, '[2]'::json), (1, '[1]'::json);
  39. contains:PARTITION BY column m has unsupported type
  40. > CREATE TABLE integers_table (n int) WITH (PARTITION BY (n));
  41. > CREATE TABLE integers_strings_table (n int, m text) WITH (PARTITION BY (n, m));
  42. ! CREATE TABLE out_of_order (n int, m text) WITH (PARTITION BY (m, n));
  43. contains:PARTITION BY columns should be a prefix
  44. ! CREATE TABLE out_of_order (n int, m text) WITH (PARTITION BY (m));
  45. contains:PARTITION BY columns should be a prefix
  46. ! CREATE TABLE unsupported_type (n int, m jsonb) WITH (PARTITION BY (n, m));
  47. contains:PARTITION BY column m has unsupported type
  48. > CREATE TABLE bids FROM SOURCE auction_house (REFERENCE bids) WITH (PARTITION BY (id));
  49. > CREATE TABLE bids_2 FROM SOURCE auction_house (REFERENCE bids) WITH (PARTITION BY (id, buyer));
  50. ! CREATE TABLE out_of_order FROM SOURCE auction_house (REFERENCE bids) WITH (PARTITION BY (buyer, id));
  51. contains:PARTITION BY columns should be a prefix
  52. ! CREATE TABLE out_of_order FROM SOURCE auction_house (REFERENCE bids) WITH (PARTITION BY (buyer));
  53. contains:PARTITION BY columns should be a prefix