From c655db6dbeace1438bb0104613754bdbe833df3b Mon Sep 17 00:00:00 2001 From: rich7420 Date: Mon, 14 Sep 2026 16:38:49 +0800 Subject: [PATCH] test: cover regex expression routing configurations --- .../string/routing_regex_all_disabled.sql | 32 ++++++++++++ .../string/routing_regex_all_enabled.sql | 32 ++++++++++++ .../string/routing_regex_all_opt_in.sql | 32 ++++++++++++ .../string/routing_regex_disabled.sql | 49 +++++++++++++++++++ .../string/routing_regex_enabled.sql | 49 +++++++++++++++++++ .../string/routing_regex_opt_in.sql | 49 +++++++++++++++++++ 6 files changed, 243 insertions(+) create mode 100644 spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_disabled.sql create mode 100644 spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_enabled.sql create mode 100644 spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_opt_in.sql create mode 100644 spark/src/test/resources/sql-tests/expressions/string/routing_regex_disabled.sql create mode 100644 spark/src/test/resources/sql-tests/expressions/string/routing_regex_enabled.sql create mode 100644 spark/src/test/resources/sql-tests/expressions/string/routing_regex_opt_in.sql diff --git a/spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_disabled.sql b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_disabled.sql new file mode 100644 index 0000000000..142aa430f1 --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_disabled.sql @@ -0,0 +1,32 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- MinSparkVersion: 3.5 +-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false +-- Config: spark.comet.expression.RegExpExtractAll.allowIncompatible=false + +statement +CREATE TABLE routing_regex_all(s STRING, p STRING, i INT) USING parquet + +statement +INSERT INTO routing_regex_all VALUES ('ab12ab', '(ab)', 1), ('', '(ab)', 1), (NULL, '(ab)', 1) + +query expect_fallback(regexp_extract_all: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT regexp_extract_all(s, '(ab)', 1) FROM routing_regex_all + +query expect_fallback(regexp_extract_all: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT regexp_extract_all(s, p, i) FROM routing_regex_all diff --git a/spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_enabled.sql b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_enabled.sql new file mode 100644 index 0000000000..ebcb92f05a --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_enabled.sql @@ -0,0 +1,32 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- MinSparkVersion: 3.5 +-- Config: spark.comet.exec.scalaUDF.codegen.enabled=true +-- Config: spark.comet.expression.RegExpExtractAll.allowIncompatible=false + +statement +CREATE TABLE routing_regex_all(s STRING, p STRING, i INT) USING parquet + +statement +INSERT INTO routing_regex_all VALUES ('ab12ab', '(ab)', 1), ('', '(ab)', 1), (NULL, '(ab)', 1) + +query expect_dispatch(regexp_extract_all) +SELECT regexp_extract_all(s, '(ab)', 1) FROM routing_regex_all + +query expect_dispatch(regexp_extract_all) +SELECT regexp_extract_all(s, p, i) FROM routing_regex_all diff --git a/spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_opt_in.sql b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_opt_in.sql new file mode 100644 index 0000000000..1edddec691 --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_all_opt_in.sql @@ -0,0 +1,32 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- MinSparkVersion: 3.5 +-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false +-- Config: spark.comet.expression.RegExpExtractAll.allowIncompatible=true + +statement +CREATE TABLE routing_regex_all(s STRING, p STRING, i INT) USING parquet + +statement +INSERT INTO routing_regex_all VALUES ('ab12ab', '(ab)', 1), ('', '(ab)', 1), (NULL, '(ab)', 1) + +query expect_native(regexp_extract_all) +SELECT regexp_extract_all(s, '(ab)', 1) FROM routing_regex_all + +query expect_fallback(regexp_extract_all: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT regexp_extract_all(s, p, i) FROM routing_regex_all diff --git a/spark/src/test/resources/sql-tests/expressions/string/routing_regex_disabled.sql b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_disabled.sql new file mode 100644 index 0000000000..b0a8c2e06e --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_disabled.sql @@ -0,0 +1,49 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false +-- Config: spark.comet.expression.RLike.allowIncompatible=false +-- Config: spark.comet.expression.RegExpExtract.allowIncompatible=false +-- Config: spark.comet.expression.RegExpReplace.allowIncompatible=false +-- Config: spark.comet.expression.StringSplit.allowIncompatible=false + +statement +CREATE TABLE routing_regex(s STRING, p STRING, i INT) USING parquet + +statement +INSERT INTO routing_regex VALUES ('ab12ab', '(ab)', 1), ('', '(ab)', 1), (NULL, '(ab)', 1) + +query expect_fallback(rlike: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT s RLIKE '(ab)' FROM routing_regex + +query expect_fallback(rlike: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT s RLIKE p FROM routing_regex + +query expect_fallback(regexp_extract: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT regexp_extract(s, '(ab)', 1) FROM routing_regex + +query expect_fallback(regexp_extract: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT regexp_extract(s, p, i) FROM routing_regex + +query expect_fallback(regexp_replace: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT regexp_replace(s, 'ab', 'x') FROM routing_regex + +query expect_fallback(regexp_replace: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT regexp_replace(s, 'ab', 'x', 2) FROM routing_regex + +query expect_fallback(split: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT split(s, 'ab') FROM routing_regex diff --git a/spark/src/test/resources/sql-tests/expressions/string/routing_regex_enabled.sql b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_enabled.sql new file mode 100644 index 0000000000..a86484b3da --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_enabled.sql @@ -0,0 +1,49 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- Config: spark.comet.exec.scalaUDF.codegen.enabled=true +-- Config: spark.comet.expression.RLike.allowIncompatible=false +-- Config: spark.comet.expression.RegExpExtract.allowIncompatible=false +-- Config: spark.comet.expression.RegExpReplace.allowIncompatible=false +-- Config: spark.comet.expression.StringSplit.allowIncompatible=false + +statement +CREATE TABLE routing_regex(s STRING, p STRING, i INT) USING parquet + +statement +INSERT INTO routing_regex VALUES ('ab12ab', '(ab)', 1), ('', '(ab)', 1), (NULL, '(ab)', 1) + +query expect_dispatch(rlike) +SELECT s RLIKE '(ab)' FROM routing_regex + +query expect_dispatch(rlike) +SELECT s RLIKE p FROM routing_regex + +query expect_dispatch(regexp_extract) +SELECT regexp_extract(s, '(ab)', 1) FROM routing_regex + +query expect_dispatch(regexp_extract) +SELECT regexp_extract(s, p, i) FROM routing_regex + +query expect_dispatch(regexp_replace) +SELECT regexp_replace(s, 'ab', 'x') FROM routing_regex + +query expect_dispatch(regexp_replace) +SELECT regexp_replace(s, 'ab', 'x', 2) FROM routing_regex + +query expect_dispatch(split) +SELECT split(s, 'ab') FROM routing_regex diff --git a/spark/src/test/resources/sql-tests/expressions/string/routing_regex_opt_in.sql b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_opt_in.sql new file mode 100644 index 0000000000..6debb7e490 --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/string/routing_regex_opt_in.sql @@ -0,0 +1,49 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false +-- Config: spark.comet.expression.RLike.allowIncompatible=true +-- Config: spark.comet.expression.RegExpExtract.allowIncompatible=true +-- Config: spark.comet.expression.RegExpReplace.allowIncompatible=true +-- Config: spark.comet.expression.StringSplit.allowIncompatible=true + +statement +CREATE TABLE routing_regex(s STRING, p STRING, i INT) USING parquet + +statement +INSERT INTO routing_regex VALUES ('ab12ab', '(ab)', 1), ('', '(ab)', 1), (NULL, '(ab)', 1) + +query expect_native(rlike) +SELECT s RLIKE '(ab)' FROM routing_regex + +query expect_fallback(rlike: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT s RLIKE p FROM routing_regex + +query expect_native(regexp_extract) +SELECT regexp_extract(s, '(ab)', 1) FROM routing_regex + +query expect_fallback(regexp_extract: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT regexp_extract(s, p, i) FROM routing_regex + +query expect_native(regexp_replace) +SELECT regexp_replace(s, 'ab', 'x') FROM routing_regex + +query expect_fallback(regexp_replace: spark.comet.exec.scalaUDF.codegen.enabled=false) +SELECT regexp_replace(s, 'ab', 'x', 2) FROM routing_regex + +query expect_native(split) +SELECT split(s, 'ab') FROM routing_regex