@@ -44,7 +44,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
4444 LocalRelation (' i .int, ' b .boolean, ' a .array(IntegerType ), ' m .map(IntegerType , IntegerType ))
4545 private val anotherTestRelation = LocalRelation (' d .int)
4646
47- test(" if (cond, trueVal, false) => And (cond, trueVal)" ) {
47+ test(" IF (cond, trueVal, false) => AND (cond, trueVal)" ) {
4848 val originalCond = If (
4949 UnresolvedAttribute (" i" ) > Literal (10 ),
5050 UnresolvedAttribute (" b" ),
@@ -59,7 +59,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
5959 testProjection(originalCond, expectedExpr = originalCond)
6060 }
6161
62- test(" if (cond, trueVal, true) => or(not (cond), trueVal)" ) {
62+ test(" IF (cond, trueVal, true) => OR(NOT (cond), trueVal)" ) {
6363 val originalCond = If (
6464 UnresolvedAttribute (" i" ) > Literal (10 ),
6565 UnresolvedAttribute (" b" ),
@@ -74,7 +74,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
7474 testProjection(originalCond, expectedExpr = originalCond)
7575 }
7676
77- test(" if (cond, false, falseVal) => and(not (cond), falseVal )" ) {
77+ test(" IF (cond, false, falseVal) => AND(NOT (cond), elseVal )" ) {
7878 val originalCond = If (
7979 UnresolvedAttribute (" i" ) > Literal (10 ),
8080 FalseLiteral ,
@@ -89,7 +89,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
8989 testProjection(originalCond, expectedExpr = originalCond)
9090 }
9191
92- test(" if (cond, true, falseVal) => or (cond, falseVal )" ) {
92+ test(" IF (cond, true, falseVal) => OR (cond, elseVal )" ) {
9393 val originalCond = If (
9494 UnresolvedAttribute (" i" ) > Literal (10 ),
9595 TrueLiteral ,
@@ -104,8 +104,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
104104 testProjection(originalCond, expectedExpr = originalCond)
105105 }
106106
107-
108- test(" case when cond then trueVal else false end => And(cond, trueVal)" ) {
107+ test(" CASE WHEN cond THEN trueVal ELSE false END => AND(cond, trueVal)" ) {
109108 Seq (Some (FalseLiteral ), None , Some (Literal (null , BooleanType ))).foreach { elseExp =>
110109 val originalCond = CaseWhen (
111110 Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), UnresolvedAttribute (" b" ))),
@@ -121,7 +120,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
121120 }
122121 }
123122
124- test(" case when cond then trueVal else true end => or(not (cond), trueVal)" ) {
123+ test(" CASE WHEN cond THEN trueVal ELSE true END => OR(NOT (cond), trueVal)" ) {
125124 val originalCond = CaseWhen (
126125 Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), UnresolvedAttribute (" b" ))),
127126 TrueLiteral )
@@ -135,8 +134,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
135134 testProjection(originalCond, expectedExpr = originalCond)
136135 }
137136
138- test(" case when cond then false else elseValue end => and(not(cond), elseValue)" ) {
139- Seq ()
137+ test(" CASE WHEN cond THEN false ELSE elseVal END => AND(NOT(cond), elseVal)" ) {
140138 val originalCond = CaseWhen (
141139 Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), FalseLiteral )),
142140 UnresolvedAttribute (" b" ))
@@ -150,7 +148,17 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
150148 testProjection(originalCond, expectedExpr = originalCond)
151149 }
152150
153- test(" case when cond then true else elseValue end => or(cond, elseValue)" ) {
151+ test(" CASE WHEN cond THEN false END => false" ) {
152+ val originalCond = CaseWhen (
153+ Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), FalseLiteral )))
154+ testFilter(originalCond, expectedCond = FalseLiteral )
155+ testJoin(originalCond, expectedCond = FalseLiteral )
156+ testDelete(originalCond, expectedCond = FalseLiteral )
157+ testUpdate(originalCond, expectedCond = FalseLiteral )
158+ testProjection(originalCond, expectedExpr = originalCond)
159+ }
160+
161+ test(" CASE WHEN cond THEN true ELSE elseVal END => OR(cond, elseVal)" ) {
154162 val originalCond = CaseWhen (
155163 Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), TrueLiteral )),
156164 UnresolvedAttribute (" b" ))
@@ -164,7 +172,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
164172 testProjection(originalCond, expectedExpr = originalCond)
165173 }
166174
167- test(" case when cond then true end => or( cond, null) " ) {
175+ test(" CASE WHEN cond THEN true END => cond" ) {
168176 val originalCond = CaseWhen (
169177 Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), TrueLiteral )))
170178 val expectedCond = UnresolvedAttribute (" i" ) > Literal (10 )
@@ -189,7 +197,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
189197 testProjection(originalCond, expectedExpr = originalCond)
190198 }
191199
192- test(" Not expected type - simplifyConditional " ) {
200+ test(" Not expected type - SimplifyConditionalsInPredicate " ) {
193201 val e = intercept[AnalysisException ] {
194202 testFilter(originalCond = Literal (null , IntegerType ), expectedCond = FalseLiteral )
195203 }.getMessage
0 commit comments