Skip to content

Commit ea15a95

Browse files
belieferdongjoon-hyun
authored andcommitted
[SPARK-50692][SQL] Add the LPAD and RPAD pushdown support for H2
### What changes were proposed in this pull request? This PR proposes to add the `LPAD` and `RPAD` pushdown support for H2. ### Why are the changes needed? apache#49325 added the support for `RPAD` pushdown. H2 as a built-in JDBC dialect for the test purpose, should add the `LPAD` and `RPAD` pushdown support for H2. ### Does this PR introduce _any_ user-facing change? 'Yes'. Spark will supports pushdown for `LPAD` and `RPAD` for H2. ### How was this patch tested? GA> ### Was this patch authored or co-authored using generative AI tooling? 'No'. Closes apache#50068 from beliefer/SPARK-50692. Authored-by: beliefer <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 9f637b5 commit ea15a95

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

sql/core/src/main/scala/org/apache/spark/sql/jdbc/H2Dialect.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private[sql] case class H2Dialect() extends JdbcDialect with NoLegacyJDBCError {
5252
"POWER", "SQRT", "FLOOR", "CEIL", "ROUND", "SIN", "SINH", "COS", "COSH", "TAN",
5353
"TANH", "COT", "ASIN", "ACOS", "ATAN", "ATAN2", "DEGREES", "RADIANS", "SIGN",
5454
"PI", "SUBSTRING", "UPPER", "LOWER", "TRANSLATE", "TRIM", "MD5", "SHA1", "SHA2",
55-
"BIT_LENGTH", "CHAR_LENGTH", "CONCAT")
55+
"BIT_LENGTH", "CHAR_LENGTH", "CONCAT", "RPAD", "LPAD")
5656

5757
override def isSupportedFunction(funcName: String): Boolean =
5858
supportedFunctions.contains(funcName)

sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala

+10
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,16 @@ class JDBCV2Suite extends QueryTest with SharedSparkSession with ExplainSuiteHel
19221922
checkFiltersRemoved(df8)
19231923
checkPushedInfo(df8, "[(CONCAT(NAME, ',', CAST(SALARY AS string))) = 'cathy,9000.00']")
19241924
checkAnswer(df8, Seq(Row(1, "cathy", 9000, 1200, false)))
1925+
1926+
val df9 = sql("SELECT * FROM h2.test.employee WHERE " +
1927+
"lpad(name, 5, '*') = '**amy'")
1928+
checkPushedInfo(df9, "[NAME IS NOT NULL, (LPAD(NAME, 5, '*')) = '**amy']")
1929+
checkAnswer(df9, Seq(Row(1, "amy", 10000, 1000, true)))
1930+
1931+
val df10 = sql("SELECT * FROM h2.test.employee WHERE " +
1932+
"rpad(name, 5, '*') = 'jen**'")
1933+
checkPushedInfo(df10, "[NAME IS NOT NULL, (RPAD(NAME, 5, '*')) = 'jen**']")
1934+
checkAnswer(df10, Seq(Row(6, "jen", 12000, 1200, true)))
19251935
}
19261936

19271937
test("scan with aggregate push-down: MAX AVG with filter and group by") {

0 commit comments

Comments
 (0)