4_text_dataflow.slt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. statement ok
  19. CREATE TABLE t_operator (op_val TEXT);
  20. statement ok
  21. INSERT INTO t_operator VALUES ('%bCd%');
  22. # DIFF TO CONSTANT FOLDING (ILIKE on TEXT)!
  23. # to be addressed with https://github.com/MaterializeInc/database-issues/issues/5462
  24. query T
  25. SELECT * FROM t_data
  26. WHERE f1 ILIKE (SELECT op_val FROM t_operator)
  27. ORDER BY f1;
  28. ----
  29. ABCDEF
  30. AbCdEf
  31. aBcDeF
  32. abcdef
  33. query T multiline
  34. EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR SELECT * FROM t_data
  35. WHERE f1 ILIKE (SELECT op_val FROM t_operator);
  36. ----
  37. Explained Query:
  38. Project (#0{f1})
  39. Filter (#0{f1} ilike #1{op_val})
  40. CrossJoin type=differential
  41. ArrangeBy keys=[[]]
  42. ReadStorage materialize.public.t_data
  43. ArrangeBy keys=[[]]
  44. Union
  45. ReadStorage materialize.public.t_operator
  46. Project (#1)
  47. FlatMap guard_subquery_size(#0{count})
  48. Reduce aggregates=[count(*)]
  49. Project ()
  50. ReadStorage materialize.public.t_operator
  51. Source materialize.public.t_data
  52. Source materialize.public.t_operator
  53. Target cluster: quickstart
  54. EOF
  55. # -------------------------------
  56. # Further text operators
  57. # -------------------------------
  58. statement ok
  59. CREATE TABLE t_using_dataflow_rendering (f1 TEXT, f2 TEXT, f3 TEXT, f4 TEXT, f1ls TEXT, f1rs TEXT);
  60. statement ok
  61. INSERT INTO t_using_dataflow_rendering VALUES ('ABCDef', 'CD', 'cd', 'XX', ' ABCDef', 'ABCDef ');
  62. query TTTTTTTTTTTTTTTTT
  63. SELECT
  64. f1 || f4,
  65. UPPER(f1), LOWER(f1),
  66. SUBSTRING(f1, 1),
  67. REPLACE(f1, f2, f3),
  68. POSITION(f2 IN f1),
  69. SPLIT_PART(f1, f2, 1),
  70. TRANSLATE(f1, 'C', 'Z'),
  71. BTRIM(f1ls), LTRIM(f1ls),
  72. BTRIM(f1rs), RTRIM(f1rs),
  73. LPAD(f1, 1),
  74. LPAD(f1, 10),
  75. LPAD(f1, 10, f2),
  76. REGEXP_MATCH(f1, f2),
  77. REGEXP_MATCH(f1, f3, 'i') AS case_insensitive
  78. FROM t_using_dataflow_rendering;
  79. ----
  80. ABCDefXX
  81. ABCDEF
  82. abcdef
  83. ABCDef
  84. ABcdef
  85. 3
  86. AB
  87. ABZDef
  88. ABCDef
  89. ABCDef
  90. ABCDef
  91. ABCDef
  92. A
  93. ABCDef
  94. CDCDABCDef
  95. {CD}
  96. {CD}
  97. query T multiline
  98. EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR
  99. SELECT
  100. f1 || f4,
  101. UPPER(f1), LOWER(f1),
  102. SUBSTRING(f1, 1),
  103. REPLACE(f1, f2, f3),
  104. POSITION(f2 IN f1),
  105. SPLIT_PART(f1, f2, 1),
  106. TRANSLATE(f1, 'C', 'Z'),
  107. BTRIM(f1ls), LTRIM(f1ls),
  108. BTRIM(f1rs), RTRIM(f1rs),
  109. LPAD(f1, 1),
  110. LPAD(f1, 10),
  111. LPAD(f1, 10, f2),
  112. REGEXP_MATCH(f1, f2),
  113. REGEXP_MATCH(f1, f3, 'i') AS case_insensitive
  114. FROM t_using_dataflow_rendering;
  115. ----
  116. Explained Query:
  117. Project (#6..=#22)
  118. Map ((#0{f1} || #3{f4}), upper(#0{f1}), lower(#0{f1}), substr(#0{f1}, 1), replace(#0{f1}, #1{f2}, #2{f3}), position(#1{f2}, #0{f1}), split_string(#0{f1}, #1{f2}, 1), translate(#0{f1}, "C", "Z"), btrim(#4{f1ls}), ltrim(#4{f1ls}), btrim(#5{f1rs}), rtrim(#5{f1rs}), lpad(#0{f1}, 1), lpad(#0{f1}, 10), lpad(#0{f1}, 10, #1{f2}), regexp_match(#0{f1}, #1{f2}), regexp_match(#0{f1}, #2{f3}, "i"))
  119. ReadStorage materialize.public.t_using_dataflow_rendering
  120. Source materialize.public.t_using_dataflow_rendering
  121. Target cluster: quickstart
  122. EOF