Skip to content

Commit 114eec6

Browse files
committed
Add test
1 parent b8b5d0e commit 114eec6

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

datafusion/sqllogictest/test_files/regexp/regexp_replace.slt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,20 @@ test.org
143143
example.com
144144
not-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.

0 commit comments

Comments
 (0)