ClickHouse/tests/queries/0_stateless/00936_substring_utf8_non_const.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
2.8 KiB
MySQL
Raw Normal View History

2019-04-12 00:36:27 +00:00
SELECT substringUTF8('hello, привет', 1, number) FROM numbers(16);
SELECT substringUTF8('hello, привет', number + 1, 3) FROM numbers(16);
SELECT substringUTF8('hello, привет', number + 1, number) FROM numbers(16);
SELECT substringUTF8('hello, привет', -1 - number, 5) FROM numbers(16);
SELECT substringUTF8('hello, привет', -1 - number) FROM numbers(16);
SELECT substringUTF8('hello, привет', 1 + number) FROM numbers(16);
SELECT substringUTF8('hello, привет', 1) FROM numbers(3);
SELECT substringUTF8('hello, привет', 5) FROM numbers(3);
SELECT substringUTF8('hello, привет', 1, 10) FROM numbers(3);
SELECT substringUTF8('hello, привет', 5, 5) FROM numbers(3);
SELECT substringUTF8('hello, привет', -5) FROM numbers(3);
SELECT substringUTF8('hello, привет', -10, 5) FROM numbers(3);
SELECT substringUTF8(materialize('hello, привет'), 1, number) FROM numbers(16);
SELECT substringUTF8(materialize('hello, привет'), number + 1, 3) FROM numbers(16);
SELECT substringUTF8(materialize('hello, привет'), number + 1, number) FROM numbers(16);
SELECT substringUTF8(materialize('hello, привет'), -1 - number, 5) FROM numbers(16);
SELECT substringUTF8(materialize('hello, привет'), -1 - number) FROM numbers(16);
SELECT substringUTF8(materialize('hello, привет'), 1 + number) FROM numbers(16);
SELECT substringUTF8(materialize('hello, привет'), 1) FROM numbers(3);
SELECT substringUTF8(materialize('hello, привет'), 5) FROM numbers(3);
SELECT substringUTF8(materialize('hello, привет'), 1, 10) FROM numbers(3);
SELECT substringUTF8(materialize('hello, привет'), 5, 5) FROM numbers(3);
SELECT substringUTF8(materialize('hello, привет'), -5) FROM numbers(3);
SELECT substringUTF8(materialize('hello, привет'), -10, 5) FROM numbers(3);
2019-04-12 00:55:50 +00:00
SELECT DISTINCT substring(toString(range(rand(1) % 50)), rand(2) % 50, rand(3) % 50) = substringUTF8(toString(range(rand(1) % 50)), rand(2) % 50, rand(3) % 50) AS res FROM numbers(1000000);
SELECT DISTINCT substring(toString(range(rand(1) % 50)), rand(2) % 50) = substringUTF8(toString(range(rand(1) % 50)), rand(2) % 50) AS res FROM numbers(1000000);
-- NOTE: The behaviour of substring and substringUTF8 is inconsistent when negative offset is greater than string size:
-- substring:
-- hello
-- ^-----^ - offset -10, length 7, result: "he"
-- substringUTF8:
-- hello
-- ^-----^ - offset -10, length 7, result: "hello"
-- SELECT DISTINCT substring(toString(range(rand(1) % 50)), -(rand(2) % 50), rand(3) % 50) = substringUTF8(toString(range(rand(1) % 50)), -(rand(2) % 50), rand(3) % 50) AS res FROM numbers(1000000);
SELECT DISTINCT substring(toString(range(rand(1) % 50)), -(rand(2) % 50)) = substringUTF8(toString(range(rand(1) % 50)), -(rand(2) % 50)) AS res FROM numbers(1000000);