Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
beliefer committed Jun 23, 2022
1 parent 92a5fb8 commit 8319ee1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@
* <li>Since version: 3.4.0</li>
* </ul>
* </li>
* <li>Name: <code>IF</code>
* <ul>
* <li>SQL semantic: <code>IF(expr1, expr2, expr3)</code></li>
* <li>Since version: 3.4.0</li>
* </ul>
* </li>
* <li>Name: <code>RAND</code>
* <ul>
* <li>SQL semantic: <code>RAND([seed])</code></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public String build(Expression expr) {
case "COALESCE":
case "GREATEST":
case "LEAST":
case "IF":
case "RAND":
case "LN":
case "EXP":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ class V2ExpressionBuilder(e: Expression, isPredicate: Boolean = false) {
} else {
None
}
case iff: If =>
val childrenExpressions = iff.children.flatMap(generateExpression(_))
if (iff.children.length == childrenExpressions.length) {
Some(new GeneralScalarExpression("IF", childrenExpressions.toArray[V2Expression]))
} else {
None
}
case Rand(child, hideSeed) =>
if (hideSeed) {
Some(new GeneralScalarExpression("RAND", Array.empty[V2Expression]))
Expand Down Expand Up @@ -223,6 +216,13 @@ class V2ExpressionBuilder(e: Expression, isPredicate: Boolean = false) {
} else {
None
}
case iff: If =>
val childrenExpressions = iff.children.flatMap(generateExpression(_))
if (iff.children.length == childrenExpressions.length) {
Some(new GeneralScalarExpression("CASE_WHEN", childrenExpressions.toArray[V2Expression]))
} else {
None
}
case substring: Substring =>
val children = if (substring.len == Literal(Integer.MAX_VALUE)) {
Seq(substring.str, substring.pos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,12 @@ class JDBCV2Suite extends QueryTest with SharedSparkSession with ExplainSuiteHel
val df12 = sql(
"""
|SELECT * FROM h2.test.employee
|WHERE IF(SALARY > 10000, BONUS, BONUS + 200) > 1200
|WHERE IF(SALARY > 10000, SALARY, LEAST(SALARY, 1000)) > 1200
|""".stripMargin)
checkFiltersRemoved(df12, false)
checkPushedInfo(df12, "PushedFilters: []")
checkAnswer(df12, Seq(Row(1, "cathy", 9000, 1200, false), Row(2, "david", 10000, 1300, true)))
checkFiltersRemoved(df12)
checkPushedInfo(df12, "PushedFilters: " +
"[(CASE WHEN SALARY > 10000.00 THEN SALARY ELSE LEAST(SALARY, 1000.00) END) > 1200.00]")
checkAnswer(df12, Seq(Row(2, "alex", 12000, 1200, false), Row(6, "jen", 12000, 1200, true)))
}

test("scan with filter push-down with ansi mode") {
Expand Down

0 comments on commit 8319ee1

Please sign in to comment.