diff --git a/connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/PlanGenerationTestSuite.scala b/connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/PlanGenerationTestSuite.scala index df7f5fb1a3e07..ebb171af9ef33 100644 --- a/connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/PlanGenerationTestSuite.scala +++ b/connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/PlanGenerationTestSuite.scala @@ -1498,7 +1498,11 @@ class PlanGenerationTestSuite fn.regexp_extract(fn.col("g"), "(\\d+)-(\\d+)", 1) } - functionTest("regexp_extract_all") { + functionTest("regexp_extract_all without regex group index") { + fn.regexp_extract_all(fn.col("g"), lit("(\\d+)([a-z]+)")) + } + + functionTest("regexp_extract_all with regex group index") { fn.regexp_extract_all(fn.col("g"), lit("(\\d+)([a-z]+)"), lit(1)) } @@ -1510,7 +1514,11 @@ class PlanGenerationTestSuite fn.regexp_substr(fn.col("g"), lit("\\d{2}(a|b|m)")) } - functionTest("regexp_instr") { + functionTest("regexp_instr without regex group index") { + fn.regexp_instr(fn.col("g"), lit("\\d+(a|b|m)")) + } + + functionTest("regexp_instr with regex group index") { fn.regexp_instr(fn.col("g"), lit("\\d+(a|b|m)"), lit(1)) } diff --git a/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_extract_all_with_regex_group_index.explain b/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_extract_all_with_regex_group_index.explain new file mode 100644 index 0000000000000..225379df43cc8 --- /dev/null +++ b/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_extract_all_with_regex_group_index.explain @@ -0,0 +1,2 @@ +Project [regexp_extract_all(g#0, (\d+)([a-z]+), 1) AS regexp_extract_all(g, (\d+)([a-z]+), 1)#0] ++- LocalRelation , [id#0L, a#0, b#0, d#0, e#0, f#0, g#0] diff --git a/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_extract_all_without_regex_group_index.explain b/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_extract_all_without_regex_group_index.explain new file mode 100644 index 0000000000000..225379df43cc8 --- /dev/null +++ b/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_extract_all_without_regex_group_index.explain @@ -0,0 +1,2 @@ +Project [regexp_extract_all(g#0, (\d+)([a-z]+), 1) AS regexp_extract_all(g, (\d+)([a-z]+), 1)#0] ++- LocalRelation , [id#0L, a#0, b#0, d#0, e#0, f#0, g#0] diff --git a/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_instr_with_regex_group_index.explain b/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_instr_with_regex_group_index.explain new file mode 100644 index 0000000000000..8ee6294b451fd --- /dev/null +++ b/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_instr_with_regex_group_index.explain @@ -0,0 +1,2 @@ +Project [regexp_instr(g#0, \d+(a|b|m), 1) AS regexp_instr(g, \d+(a|b|m), 1)#0] ++- LocalRelation , [id#0L, a#0, b#0, d#0, e#0, f#0, g#0] diff --git a/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_instr_without_regex_group_index.explain b/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_instr_without_regex_group_index.explain new file mode 100644 index 0000000000000..e2ff4394a340c --- /dev/null +++ b/connector/connect/common/src/test/resources/query-tests/explain-results/function_regexp_instr_without_regex_group_index.explain @@ -0,0 +1,2 @@ +Project [regexp_instr(g#0, \d+(a|b|m), 0) AS regexp_instr(g, \d+(a|b|m), 0)#0] ++- LocalRelation , [id#0L, a#0, b#0, d#0, e#0, f#0, g#0] diff --git a/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_with_regex_group_index.json b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_with_regex_group_index.json new file mode 100644 index 0000000000000..ebe2f581e3de2 --- /dev/null +++ b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_with_regex_group_index.json @@ -0,0 +1,33 @@ +{ + "common": { + "planId": "1" + }, + "project": { + "input": { + "common": { + "planId": "0" + }, + "localRelation": { + "schema": "struct\u003cid:bigint,a:int,b:double,d:struct\u003cid:bigint,a:int,b:double\u003e,e:array\u003cint\u003e,f:map\u003cstring,struct\u003cid:bigint,a:int,b:double\u003e\u003e,g:string\u003e" + } + }, + "expressions": [{ + "unresolvedFunction": { + "functionName": "regexp_extract_all", + "arguments": [{ + "unresolvedAttribute": { + "unparsedIdentifier": "g" + } + }, { + "literal": { + "string": "(\\d+)([a-z]+)" + } + }, { + "literal": { + "integer": 1 + } + }] + } + }] + } +} \ No newline at end of file diff --git a/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_with_regex_group_index.proto.bin b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_with_regex_group_index.proto.bin new file mode 100644 index 0000000000000..2cf31e5f75f4f Binary files /dev/null and b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_with_regex_group_index.proto.bin differ diff --git a/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_without_regex_group_index.json b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_without_regex_group_index.json new file mode 100644 index 0000000000000..84a2e378ed2e3 --- /dev/null +++ b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_without_regex_group_index.json @@ -0,0 +1,29 @@ +{ + "common": { + "planId": "1" + }, + "project": { + "input": { + "common": { + "planId": "0" + }, + "localRelation": { + "schema": "struct\u003cid:bigint,a:int,b:double,d:struct\u003cid:bigint,a:int,b:double\u003e,e:array\u003cint\u003e,f:map\u003cstring,struct\u003cid:bigint,a:int,b:double\u003e\u003e,g:string\u003e" + } + }, + "expressions": [{ + "unresolvedFunction": { + "functionName": "regexp_extract_all", + "arguments": [{ + "unresolvedAttribute": { + "unparsedIdentifier": "g" + } + }, { + "literal": { + "string": "(\\d+)([a-z]+)" + } + }] + } + }] + } +} \ No newline at end of file diff --git a/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_without_regex_group_index.proto.bin b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_without_regex_group_index.proto.bin new file mode 100644 index 0000000000000..529cae91ce595 Binary files /dev/null and b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_extract_all_without_regex_group_index.proto.bin differ diff --git a/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_with_regex_group_index.json b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_with_regex_group_index.json new file mode 100644 index 0000000000000..cb44dda5ba2c2 --- /dev/null +++ b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_with_regex_group_index.json @@ -0,0 +1,33 @@ +{ + "common": { + "planId": "1" + }, + "project": { + "input": { + "common": { + "planId": "0" + }, + "localRelation": { + "schema": "struct\u003cid:bigint,a:int,b:double,d:struct\u003cid:bigint,a:int,b:double\u003e,e:array\u003cint\u003e,f:map\u003cstring,struct\u003cid:bigint,a:int,b:double\u003e\u003e,g:string\u003e" + } + }, + "expressions": [{ + "unresolvedFunction": { + "functionName": "regexp_instr", + "arguments": [{ + "unresolvedAttribute": { + "unparsedIdentifier": "g" + } + }, { + "literal": { + "string": "\\d+(a|b|m)" + } + }, { + "literal": { + "integer": 1 + } + }] + } + }] + } +} \ No newline at end of file diff --git a/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_with_regex_group_index.proto.bin b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_with_regex_group_index.proto.bin new file mode 100644 index 0000000000000..55cc77eb3cd1f Binary files /dev/null and b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_with_regex_group_index.proto.bin differ diff --git a/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_without_regex_group_index.json b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_without_regex_group_index.json new file mode 100644 index 0000000000000..eeab13abaa6da --- /dev/null +++ b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_without_regex_group_index.json @@ -0,0 +1,29 @@ +{ + "common": { + "planId": "1" + }, + "project": { + "input": { + "common": { + "planId": "0" + }, + "localRelation": { + "schema": "struct\u003cid:bigint,a:int,b:double,d:struct\u003cid:bigint,a:int,b:double\u003e,e:array\u003cint\u003e,f:map\u003cstring,struct\u003cid:bigint,a:int,b:double\u003e\u003e,g:string\u003e" + } + }, + "expressions": [{ + "unresolvedFunction": { + "functionName": "regexp_instr", + "arguments": [{ + "unresolvedAttribute": { + "unparsedIdentifier": "g" + } + }, { + "literal": { + "string": "\\d+(a|b|m)" + } + }] + } + }] + } +} \ No newline at end of file diff --git a/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_without_regex_group_index.proto.bin b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_without_regex_group_index.proto.bin new file mode 100644 index 0000000000000..3aee655d92c65 Binary files /dev/null and b/connector/connect/common/src/test/resources/query-tests/queries/function_regexp_instr_without_regex_group_index.proto.bin differ