File tree Expand file tree Collapse file tree
datafusion/sqllogictest/test_files/regexp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,6 +143,20 @@ test.org
143143example.com
144144not-a-url
145145
146+ # More than one capture group should disable the short-regex fast path.
147+ # This still uses replacement \1, but captures_len() will be > 2, so the
148+ # implementation must fall back to the normal regexp_replace path.
149+ query T
150+ SELECT regexp_replace(url, '^https?://((www\.)?([^/]+))/.*$', '\1') FROM (VALUES
151+ ('https://www.example.com/path/to/page?q=1'),
152+ ('http://test.org/foo/bar'),
153+ ('not-a-url')
154+ ) AS t(url);
155+ ----
156+ www.example.com
157+ test.org
158+ not-a-url
159+
146160# If the overall pattern matches but capture group 1 does not participate,
147161# regexp_replace(..., '\1') should substitute the empty string, not keep
148162# the original input.
You can’t perform that action at this time.
0 commit comments