Skip to content

Commit 39da850

Browse files
authored
test: cover string expression routing and native opt-in (#5915)
1 parent 41dc7e0 commit 39da850

11 files changed

Lines changed: 405 additions & 0 deletions
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false
19+
-- Config: spark.comet.caseConversion.enabled=false
20+
21+
statement
22+
CREATE TABLE routing_case_conversion(s STRING) USING parquet
23+
24+
statement
25+
INSERT INTO routing_case_conversion VALUES ('Hello world'), (''), (NULL)
26+
27+
query expect_fallback(upper: spark.comet.exec.scalaUDF.codegen.enabled=false)
28+
SELECT upper(s) FROM routing_case_conversion
29+
30+
query expect_fallback(lower: spark.comet.exec.scalaUDF.codegen.enabled=false)
31+
SELECT lower(s) FROM routing_case_conversion
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- Config: spark.comet.exec.scalaUDF.codegen.enabled=true
19+
-- Config: spark.comet.caseConversion.enabled=false
20+
21+
statement
22+
CREATE TABLE routing_case_conversion(s STRING) USING parquet
23+
24+
statement
25+
INSERT INTO routing_case_conversion VALUES ('Hello world'), (''), (NULL)
26+
27+
query expect_dispatch(upper)
28+
SELECT upper(s) FROM routing_case_conversion
29+
30+
query expect_dispatch(lower)
31+
SELECT lower(s) FROM routing_case_conversion
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false
19+
-- Config: spark.comet.caseConversion.enabled=true
20+
21+
statement
22+
CREATE TABLE routing_case_conversion(s STRING) USING parquet
23+
24+
statement
25+
INSERT INTO routing_case_conversion VALUES ('Hello world'), (''), (NULL)
26+
27+
query expect_native(upper)
28+
SELECT upper(s) FROM routing_case_conversion
29+
30+
query expect_native(lower)
31+
SELECT lower(s) FROM routing_case_conversion
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false
19+
-- Config: spark.comet.expression.InitCap.allowIncompatible=false
20+
-- Config: spark.comet.expression.StringReplace.allowIncompatible=false
21+
-- Config: spark.comet.expression.GetJsonObject.allowIncompatible=false
22+
23+
statement
24+
CREATE TABLE routing_string_opt_in(s STRING, j STRING) USING parquet
25+
26+
statement
27+
INSERT INTO routing_string_opt_in VALUES ('hello world', '{"a":1}'), ('', '{}'), (NULL, NULL)
28+
29+
query expect_fallback(initcap: spark.comet.exec.scalaUDF.codegen.enabled=false)
30+
SELECT initcap(s) FROM routing_string_opt_in
31+
32+
query expect_fallback(replace: spark.comet.exec.scalaUDF.codegen.enabled=false)
33+
SELECT replace(s, 'l', 'L') FROM routing_string_opt_in
34+
35+
query expect_fallback(get_json_object: spark.comet.exec.scalaUDF.codegen.enabled=false)
36+
SELECT get_json_object(j, '$.a') FROM routing_string_opt_in
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- Config: spark.comet.exec.scalaUDF.codegen.enabled=true
19+
-- Config: spark.comet.expression.InitCap.allowIncompatible=false
20+
-- Config: spark.comet.expression.StringReplace.allowIncompatible=false
21+
-- Config: spark.comet.expression.GetJsonObject.allowIncompatible=false
22+
23+
statement
24+
CREATE TABLE routing_string_opt_in(s STRING, j STRING) USING parquet
25+
26+
statement
27+
INSERT INTO routing_string_opt_in VALUES ('hello world', '{"a":1}'), ('', '{}'), (NULL, NULL)
28+
29+
query expect_dispatch(initcap)
30+
SELECT initcap(s) FROM routing_string_opt_in
31+
32+
query expect_dispatch(replace)
33+
SELECT replace(s, 'l', 'L') FROM routing_string_opt_in
34+
35+
query expect_dispatch(get_json_object)
36+
SELECT get_json_object(j, '$.a') FROM routing_string_opt_in
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false
19+
-- Config: spark.comet.expression.InitCap.allowIncompatible=true
20+
-- Config: spark.comet.expression.StringReplace.allowIncompatible=true
21+
-- Config: spark.comet.expression.GetJsonObject.allowIncompatible=true
22+
23+
statement
24+
CREATE TABLE routing_string_opt_in(s STRING, j STRING) USING parquet
25+
26+
statement
27+
INSERT INTO routing_string_opt_in VALUES ('hello world', '{"a":1}'), ('', '{}'), (NULL, NULL)
28+
29+
query expect_native(initcap)
30+
SELECT initcap(s) FROM routing_string_opt_in
31+
32+
query expect_native(replace)
33+
SELECT replace(s, 'l', 'L') FROM routing_string_opt_in
34+
35+
query expect_native(get_json_object)
36+
SELECT get_json_object(j, '$.a') FROM routing_string_opt_in
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false
19+
-- Config: spark.comet.expression.StringTranslate.allowIncompatible=false
20+
21+
statement
22+
CREATE TABLE routing_strings(s STRING, p STRING, b BINARY, a ARRAY<INT>) USING parquet
23+
24+
statement
25+
INSERT INTO routing_strings VALUES ('h_llo', 'h_llo', unhex('4142'), array(1, 2)), ('hello', 'h_llo', unhex(''), array()), (NULL, NULL, NULL, NULL)
26+
27+
query expect_native(like)
28+
SELECT s LIKE p FROM routing_strings
29+
30+
query expect_native(concat)
31+
SELECT concat(s, '!') FROM routing_strings
32+
33+
query expect_native(concat_ws)
34+
SELECT concat_ws('-', s, 'x') FROM routing_strings
35+
36+
query expect_fallback(like: spark.comet.exec.scalaUDF.codegen.enabled=false)
37+
SELECT s LIKE 'h$_llo' ESCAPE '$' FROM routing_strings
38+
39+
query expect_fallback(concat: spark.comet.exec.scalaUDF.codegen.enabled=false)
40+
SELECT concat(b, b), concat(a, a) FROM routing_strings
41+
42+
query expect_fallback(concat_ws: spark.comet.exec.scalaUDF.codegen.enabled=false)
43+
SELECT concat_ws('-', 'a', 'b')
44+
45+
query expect_fallback(translate: spark.comet.exec.scalaUDF.codegen.enabled=false)
46+
SELECT translate(s, 'hl', 'HL') FROM routing_strings
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- Config: spark.comet.exec.scalaUDF.codegen.enabled=true
19+
-- Config: spark.comet.expression.StringTranslate.allowIncompatible=false
20+
21+
statement
22+
CREATE TABLE routing_strings(s STRING, p STRING, b BINARY, a ARRAY<INT>) USING parquet
23+
24+
statement
25+
INSERT INTO routing_strings VALUES ('h_llo', 'h_llo', unhex('4142'), array(1, 2)), ('hello', 'h_llo', unhex(''), array()), (NULL, NULL, NULL, NULL)
26+
27+
query expect_native(like)
28+
SELECT s LIKE p FROM routing_strings
29+
30+
query expect_native(concat)
31+
SELECT concat(s, '!') FROM routing_strings
32+
33+
query expect_native(concat_ws)
34+
SELECT concat_ws('-', s, 'x') FROM routing_strings
35+
36+
query expect_dispatch(like)
37+
SELECT s LIKE 'h$_llo' ESCAPE '$' FROM routing_strings
38+
39+
query expect_dispatch(concat)
40+
SELECT concat(b, b), concat(a, a) FROM routing_strings
41+
42+
query expect_dispatch(concat_ws)
43+
SELECT concat_ws('-', 'a', 'b')
44+
45+
query expect_dispatch(translate)
46+
SELECT translate(s, 'hl', 'HL') FROM routing_strings
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false
19+
-- Config: spark.comet.expression.StringTranslate.allowIncompatible=true
20+
21+
statement
22+
CREATE TABLE routing_strings(s STRING, p STRING, b BINARY, a ARRAY<INT>) USING parquet
23+
24+
statement
25+
INSERT INTO routing_strings VALUES ('h_llo', 'h_llo', unhex('4142'), array(1, 2)), ('hello', 'h_llo', unhex(''), array()), (NULL, NULL, NULL, NULL)
26+
27+
query expect_native(like)
28+
SELECT s LIKE p FROM routing_strings
29+
30+
query expect_native(concat)
31+
SELECT concat(s, '!') FROM routing_strings
32+
33+
query expect_native(concat_ws)
34+
SELECT concat_ws('-', s, 'x') FROM routing_strings
35+
36+
query expect_fallback(like: spark.comet.exec.scalaUDF.codegen.enabled=false)
37+
SELECT s LIKE 'h$_llo' ESCAPE '$' FROM routing_strings
38+
39+
query expect_fallback(concat: spark.comet.exec.scalaUDF.codegen.enabled=false)
40+
SELECT concat(b, b), concat(a, a) FROM routing_strings
41+
42+
query expect_fallback(concat_ws: spark.comet.exec.scalaUDF.codegen.enabled=false)
43+
SELECT concat_ws('-', 'a', 'b')
44+
45+
query expect_native(translate)
46+
SELECT translate(s, 'hl', 'HL') FROM routing_strings
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false
19+
20+
statement
21+
CREATE TABLE routing_unbase64(s STRING) USING parquet
22+
23+
statement
24+
INSERT INTO routing_unbase64 VALUES ('aGVsbG8='), (''), (NULL)
25+
26+
query expect_native(unbase64)
27+
SELECT unbase64(s) FROM routing_unbase64
28+
29+
query expect_fallback(unbase64: spark.comet.exec.scalaUDF.codegen.enabled=false)
30+
SELECT unbase64(concat(s, '')) FROM routing_unbase64
31+
32+
query expect_fallback(unbase64: spark.comet.exec.scalaUDF.codegen.enabled=false)
33+
SELECT to_binary(s, 'base64') FROM routing_unbase64

0 commit comments

Comments
 (0)