ClickHouse/tests/queries/0_stateless/02665_regexp_extract.reference
2023-02-17 18:32:56 +01:00

109 lines
4.0 KiB
Plaintext

-- { echoOn }
select regexpExtract('100-200', '(\\d+)-(\\d+)', 1);
100
select regexpExtract('100-200', '(\\d+)-(\\d+)');
100
select regexpExtract('100-200', '(\\d+)-(\\d+)', 2);
200
select regexpExtract('100-200', '(\\d+)-(\\d+)', 0);
100-200
select regexpExtract('100-200', '(\\d+).*', 1);
100
select regexpExtract('100-200', '([a-z])', 1);
select regexpExtract(null, '([a-z])', 1);
\N
select regexpExtract('100-200', null, 1);
\N
select regexpExtract('100-200', '([a-z])', null);
\N
select REGEXP_EXTRACT('100-200', '(\\d+)-(\\d+)', 1);
100
select REGEXP_EXTRACT('100-200', '(\\d+)-(\\d+)');
100
select REGEXP_EXTRACT('100-200', '(\\d+)-(\\d+)', 0);
100-200
select regexpExtract('0123456789', '(\d+)(\d+)', 0);
0123456789
select regexpExtract('0123456789', '(\d+)(\d+)', 1);
012345678
select regexpExtract('0123456789', '(\d+)(\d+)', 2);
9
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)');
100
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)', 1);
100
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)', 2);
200
select regexpExtract(materialize('100-200'), '(\\d+).*', 1);
100
select regexpExtract(materialize('100-200'), '([a-z])', 1);
select regexpExtract(materialize(null), '([a-z])', 1);
\N
select regexpExtract(materialize('100-200'), null, 1);
\N
select regexpExtract(materialize('100-200'), '([a-z])', null);
\N
select regexpExtract('100-200', '(\\d+)-(\\d+)', materialize(1));
100
select regexpExtract('100-200', '(\\d+)-(\\d+)', materialize(2));
200
select regexpExtract('100-200', '(\\d+).*', materialize(1));
100
select regexpExtract('100-200', '([a-z])', materialize(1));
select regexpExtract(null, '([a-z])', materialize(1));
\N
select regexpExtract('100-200', null, materialize(1));
\N
select regexpExtract('100-200', '([a-z])', materialize(null));
\N
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)', materialize(1));
100
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)', materialize(2));
200
select regexpExtract(materialize('100-200'), '(\\d+).*', materialize(1));
100
select regexpExtract(materialize('100-200'), '([a-z])', materialize(1));
select regexpExtract(materialize(null), '([a-z])', materialize(1));
\N
select regexpExtract(materialize('100-200'), null, materialize(1));
\N
select regexpExtract(materialize('100-200'), '([a-z])', materialize(null));
\N
select regexpExtract('100-200', '(\\d+)-(\\d+)', number) from numbers(3);
100-200
100
200
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)', number) from numbers(3);
100-200
100
200
select regexpExtract(number::String || '-' || (2*number)::String, '(\\d+)-(\\d+)', 1) from numbers(3);
0
1
2
select regexpExtract(number::String || '-' || (2*number)::String, '(\\d+)-(\\d+)', number%3) from numbers(5);
0-0
1
4
3-6
4
select regexpExtract('100-200100-200', '(\\d+)-(\\d+)(\\d+)-(\\d+)', materialize(3));
0
select regexpExtract('100-200'); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
select regexpExtract('100-200', '(\\d+)-(\\d+)', 1, 2); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
select regexpExtract(cast('100-200' as FixedString(10)), '(\\d+)-(\\d+)', 1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
select regexpExtract('100-200', cast('(\\d+)-(\\d+)' as FixedString(20)), 1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
select regexpExtract('100-200', '(\\d+)-(\\d+)', 'a'); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
select regexpExtract(100, '(\\d+)-(\\d+)', 1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
select regexpExtract('100-200', 1, 1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
select regexpExtract('100-200', materialize('(\\d+)-(\\d+)'), 1); -- { serverError ILLEGAL_COLUMN }
select regexpExtract('100-200', '(\\d+)-(\\d+)', 3); -- { serverError INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE }
select regexpExtract('100-200', '(\\d+)-(\\d+)', -1); -- { serverError INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE }
select regexpExtract('100-200', '\\d+-\\d+', 0);
100-200
select regexpExtract('100-200', '\\d+-\\d+', 1);-- { serverError INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE }