Skip to content

Commit 1cd60fa

Browse files
committed
fix
1 parent bb64039 commit 1cd60fa

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.paimon.predicate;
20+
21+
import org.apache.paimon.data.BinaryString;
22+
import org.apache.paimon.data.GenericRow;
23+
24+
import org.junit.jupiter.api.Test;
25+
26+
import java.util.ArrayList;
27+
import java.util.List;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
31+
32+
class UpperTransformTest {
33+
34+
@Test
35+
public void testNullInputs() {
36+
List<Object> inputs = new ArrayList<>();
37+
inputs.add(null);
38+
UpperTransform transform = new UpperTransform(inputs);
39+
Object result = transform.transform(GenericRow.of());
40+
assertThat(result).isNull();
41+
}
42+
43+
@Test
44+
public void testNormalInputs() {
45+
List<Object> inputs = new ArrayList<>();
46+
inputs.add(BinaryString.fromString("hello"));
47+
UpperTransform transform = new UpperTransform(inputs);
48+
Object result = transform.transform(GenericRow.of());
49+
assertThat(result).isEqualTo(BinaryString.fromString("HELLO"));
50+
}
51+
52+
@Test
53+
public void testIllegalInputs() {
54+
List<Object> inputs = new ArrayList<>();
55+
inputs.add(BinaryString.fromString("hello"));
56+
inputs.add(BinaryString.fromString("hi"));
57+
assertThatThrownBy(() -> new UpperTransform(inputs))
58+
.isInstanceOf(IllegalArgumentException.class);
59+
}
60+
}

paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/PaimonPushDownTestBase.scala

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,36 @@ abstract class PaimonPushDownTestBase extends PaimonSparkTestBase {
129129
}
130130
}
131131

132+
test(s"Paimon push down: apply UPPER") {
133+
// Spark support push down UPPER since Spark 3.4.
134+
if (gteqSpark3_4) {
135+
withTable("t") {
136+
sql("""
137+
|CREATE TABLE t (id int, value int, dt STRING)
138+
|using paimon
139+
|PARTITIONED BY (dt)
140+
|""".stripMargin)
141+
142+
sql("""
143+
|INSERT INTO t values
144+
|(1, 100, '2024', 'hello')
145+
|""".stripMargin)
146+
147+
val q =
148+
"""
149+
|SELECT * FROM t
150+
|WHERE UPPER(dt) = 'HELLO'
151+
|""".stripMargin
152+
assert(!checkFilterExists(q))
153+
154+
checkAnswer(
155+
spark.sql(q),
156+
Seq(Row(1, 100, "hello"))
157+
)
158+
}
159+
}
160+
}
161+
132162
test("Paimon pushDown: limit for append-only tables with deletion vector") {
133163
withTable("dv_test") {
134164
spark.sql(

0 commit comments

Comments
 (0)