4_text_folding.slt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. # use mode standard due to spaces (and to allow easier file comparisons with the other computation mode)
  10. mode standard
  11. # -------------------------------
  12. # ILIKE operator
  13. # -------------------------------
  14. statement ok
  15. CREATE TABLE t_data (f1 TEXT);
  16. statement ok
  17. INSERT INTO t_data VALUES ('ABCDEF'), ('abcdef'), ('aBcDeF'), ('AbCdEf');
  18. query T
  19. SELECT * FROM t_data
  20. WHERE f1 ILIKE '%bCd%'
  21. ORDER BY f1;
  22. ----
  23. ABCDEF
  24. AbCdEf
  25. aBcDeF
  26. abcdef
  27. query T multiline
  28. EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR SELECT * FROM t_data
  29. WHERE f1 ILIKE '%bCd%';
  30. ----
  31. Explained Query:
  32. Filter ilike["%bCd%"](#0{f1})
  33. ReadStorage materialize.public.t_data
  34. Source materialize.public.t_data
  35. filter=(ilike["%bCd%"](#0{f1}))
  36. Target cluster: quickstart
  37. EOF
  38. # -------------------------------
  39. # Further text operators
  40. # -------------------------------
  41. statement ok
  42. CREATE VIEW v_using_constant_folding (f1, f2, f3, f4, f1ls, f1rs) AS
  43. SELECT
  44. 'ABCDef', 'CD', 'cd', 'XX', ' ABCDef', 'ABCDef ';
  45. query TTTTTTTTTTTTTTTTT
  46. SELECT
  47. f1 || f4,
  48. UPPER(f1), LOWER(f1),
  49. SUBSTRING(f1, 1),
  50. REPLACE(f1, f2, f3),
  51. POSITION(f2 IN f1),
  52. SPLIT_PART(f1, f2, 1),
  53. TRANSLATE(f1, 'C', 'Z'),
  54. BTRIM(f1ls), LTRIM(f1ls),
  55. BTRIM(f1rs), RTRIM(f1rs),
  56. LPAD(f1, 1),
  57. LPAD(f1, 10),
  58. LPAD(f1, 10, f2),
  59. REGEXP_MATCH(f1, f2),
  60. REGEXP_MATCH(f1, f3, 'i') AS case_insensitive
  61. FROM v_using_constant_folding;
  62. ----
  63. ABCDefXX
  64. ABCDEF
  65. abcdef
  66. ABCDef
  67. ABcdef
  68. 3
  69. AB
  70. ABZDef
  71. ABCDef
  72. ABCDef
  73. ABCDef
  74. ABCDef
  75. A
  76. ABCDef
  77. CDCDABCDef
  78. {CD}
  79. {CD}
  80. query T multiline
  81. EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR
  82. SELECT
  83. f1 || f4,
  84. UPPER(f1), LOWER(f1),
  85. SUBSTRING(f1, 1),
  86. REPLACE(f1, f2, f3),
  87. POSITION(f2 IN f1),
  88. SPLIT_PART(f1, f2, 1),
  89. TRANSLATE(f1, 'C', 'Z'),
  90. BTRIM(f1ls), LTRIM(f1ls),
  91. BTRIM(f1rs), RTRIM(f1rs),
  92. LPAD(f1, 1),
  93. LPAD(f1, 10),
  94. LPAD(f1, 10, f2),
  95. REGEXP_MATCH(f1, f2),
  96. REGEXP_MATCH(f1, f3, 'i') AS case_insensitive
  97. FROM v_using_constant_folding;
  98. ----
  99. Explained Query (fast path):
  100. Constant
  101. - ("ABCDefXX", "ABCDEF", "abcdef", "ABCDef", "ABcdef", 3, "AB", "ABZDef", "ABCDef", "ABCDef", "ABCDef", "ABCDef", "A", " ABCDef", "CDCDABCDef", {"CD"}, {"CD"})
  102. Target cluster: quickstart
  103. EOF