pretty.slt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. # Test requires stable object IDs
  10. reset-server
  11. query T
  12. SELECT pretty_sql('select 1,2,3')
  13. ----
  14. SELECT 1, 2, 3;
  15. query T multiline
  16. SELECT pretty_sql('select 1,2,3', 0)
  17. ----
  18. SELECT
  19. 1,
  20. 2,
  21. 3;
  22. EOF
  23. query T
  24. SELECT pretty_sql('select 1,2,3', 100)
  25. ----
  26. SELECT 1, 2, 3;
  27. query error invalid width
  28. SELECT pretty_sql('select 1,2,3', -1)
  29. query error expected exactly one statement
  30. SELECT pretty_sql('select 1; select 2')
  31. query error expected exactly one statement
  32. SELECT pretty_sql('')
  33. query error expected exactly one statement
  34. SELECT pretty_sql(';')
  35. simple conn=mz_system,user=mz_system
  36. ALTER SYSTEM SET enable_connection_validation_syntax TO true;
  37. ----
  38. COMPLETE 0
  39. statement ok
  40. CREATE CONNECTION kafka_conn TO KAFKA (BROKER 'localhost:9092', SECURITY PROTOCOL PLAINTEXT) WITH (VALIDATE = false);
  41. query T multiline
  42. SELECT pretty_sql(create_sql) FROM mz_connections WHERE name = 'kafka_conn'
  43. ----
  44. CREATE CONNECTION materialize.public.kafka_conn TO KAFKA (BROKER = 'localhost:9092', SECURITY PROTOCOL = plaintext);
  45. EOF
  46. statement ok
  47. CREATE TABLE t (i INT)
  48. query T multiline
  49. SELECT pretty_sql(create_sql) FROM mz_tables WHERE name = 't'
  50. ----
  51. CREATE TABLE materialize.public.t (i [s20 AS pg_catalog.int4]);
  52. EOF
  53. statement ok
  54. CREATE DEFAULT INDEX ON t
  55. query T multiline
  56. SELECT replace(pretty_sql(create_sql), on_id, '<on_id>') FROM mz_indexes WHERE name = 't_primary_idx'
  57. ----
  58. CREATE INDEX t_primary_idx IN CLUSTER [u1] ON [<on_id> AS materialize.public.t] (i);
  59. EOF
  60. statement ok
  61. CREATE VIEW v AS SELECT 1
  62. query T multiline
  63. SELECT pretty_sql(create_sql) FROM mz_views WHERE name = 'v'
  64. ----
  65. CREATE VIEW materialize.public.v AS SELECT 1;
  66. EOF
  67. statement ok
  68. CREATE SOURCE s FROM LOAD GENERATOR COUNTER
  69. query T multiline
  70. SELECT regexp_replace(create_sql, 'u[0-9]+', 'uX', 'g') FROM mz_sources WHERE name = 's'
  71. ----
  72. CREATE SOURCE "materialize"."public"."s" IN CLUSTER [uX] FROM LOAD GENERATOR COUNTER EXPOSE PROGRESS AS [uX AS "materialize"."public"."s_progress"]
  73. EOF
  74. statement ok
  75. CREATE TYPE ty AS LIST (ELEMENT TYPE=bool)
  76. query T multiline
  77. SELECT pretty_sql(create_sql) FROM mz_types WHERE name = 'ty'
  78. ----
  79. CREATE TYPE materialize.public.ty AS LIST (ELEMENT TYPE = [s6 AS pg_catalog.bool]);
  80. EOF