tanclary commented on code in PR #3369:
URL: https://github.com/apache/calcite/pull/3369#discussion_r1305965977
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -4568,6 +4568,25 @@ private static void checkIf(SqlOperatorFixture f) {
f.checkNull("regexp_contains(cast(null as varchar), cast(null as
varchar))");
}
+ @Test void testRegexpExtractFunc() {
+ final SqlOperatorFixture f =
+
fixture().setFor(SqlLibraryOperators.REGEXP_EXTRACT).withLibrary(SqlLibrary.BIG_QUERY);
+
+ f.checkString("regexp_extract('abc def ghi', 'def')", "def", "VARCHAR NOT
NULL");
+ f.checkString("regexp_extract('abcadcaecghi', 'a.c', 1, 3)", "aec",
"VARCHAR NOT NULL");
+ f.checkString("regexp_extract('abcadcaecghi', 'abc(a.c)')", "adc",
"VARCHAR NOT NULL");
+ f.checkString("regexp_extract('55as56664as422', '\\d{3}')", "566",
"VARCHAR NOT NULL");
+
+ f.checkNull("regexp_extract('abc def ghi', 'asd')");
+ f.checkNull("regexp_extract('abc def ghi', cast(null as varchar))");
Review Comment:
I think it might be best to add some to `SqlOperatorTest` because that seems
to serve as the main source of truth for how operators handle their edge cases,
I don't necessarily think it's redundant. The operator tests check and showcase
that the operator follows the behavior it should, while the function tests show
that the actual implementation abides by that behavior as well. What do you
think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]