@@ -44,7 +44,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
44
44
LocalRelation (' i .int, ' b .boolean, ' a .array(IntegerType ), ' m .map(IntegerType , IntegerType ))
45
45
private val anotherTestRelation = LocalRelation (' d .int)
46
46
47
- test(" if (cond, trueVal, false) => And (cond, trueVal)" ) {
47
+ test(" IF (cond, trueVal, false) => AND (cond, trueVal)" ) {
48
48
val originalCond = If (
49
49
UnresolvedAttribute (" i" ) > Literal (10 ),
50
50
UnresolvedAttribute (" b" ),
@@ -59,7 +59,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
59
59
testProjection(originalCond, expectedExpr = originalCond)
60
60
}
61
61
62
- test(" if (cond, trueVal, true) => or(not (cond), trueVal)" ) {
62
+ test(" IF (cond, trueVal, true) => OR(NOT (cond), trueVal)" ) {
63
63
val originalCond = If (
64
64
UnresolvedAttribute (" i" ) > Literal (10 ),
65
65
UnresolvedAttribute (" b" ),
@@ -74,7 +74,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
74
74
testProjection(originalCond, expectedExpr = originalCond)
75
75
}
76
76
77
- test(" if (cond, false, falseVal) => and(not (cond), falseVal )" ) {
77
+ test(" IF (cond, false, falseVal) => AND(NOT (cond), elseVal )" ) {
78
78
val originalCond = If (
79
79
UnresolvedAttribute (" i" ) > Literal (10 ),
80
80
FalseLiteral ,
@@ -89,7 +89,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
89
89
testProjection(originalCond, expectedExpr = originalCond)
90
90
}
91
91
92
- test(" if (cond, true, falseVal) => or (cond, falseVal )" ) {
92
+ test(" IF (cond, true, falseVal) => OR (cond, elseVal )" ) {
93
93
val originalCond = If (
94
94
UnresolvedAttribute (" i" ) > Literal (10 ),
95
95
TrueLiteral ,
@@ -104,8 +104,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
104
104
testProjection(originalCond, expectedExpr = originalCond)
105
105
}
106
106
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)" ) {
109
108
Seq (Some (FalseLiteral ), None , Some (Literal (null , BooleanType ))).foreach { elseExp =>
110
109
val originalCond = CaseWhen (
111
110
Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), UnresolvedAttribute (" b" ))),
@@ -121,7 +120,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
121
120
}
122
121
}
123
122
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)" ) {
125
124
val originalCond = CaseWhen (
126
125
Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), UnresolvedAttribute (" b" ))),
127
126
TrueLiteral )
@@ -135,8 +134,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
135
134
testProjection(originalCond, expectedExpr = originalCond)
136
135
}
137
136
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)" ) {
140
138
val originalCond = CaseWhen (
141
139
Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), FalseLiteral )),
142
140
UnresolvedAttribute (" b" ))
@@ -150,7 +148,17 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
150
148
testProjection(originalCond, expectedExpr = originalCond)
151
149
}
152
150
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)" ) {
154
162
val originalCond = CaseWhen (
155
163
Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), TrueLiteral )),
156
164
UnresolvedAttribute (" b" ))
@@ -164,7 +172,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
164
172
testProjection(originalCond, expectedExpr = originalCond)
165
173
}
166
174
167
- test(" case when cond then true end => or( cond, null) " ) {
175
+ test(" CASE WHEN cond THEN true END => cond" ) {
168
176
val originalCond = CaseWhen (
169
177
Seq ((UnresolvedAttribute (" i" ) > Literal (10 ), TrueLiteral )))
170
178
val expectedCond = UnresolvedAttribute (" i" ) > Literal (10 )
@@ -189,7 +197,7 @@ class SimplifyConditionalsInPredicateSuite extends PlanTest {
189
197
testProjection(originalCond, expectedExpr = originalCond)
190
198
}
191
199
192
- test(" Not expected type - simplifyConditional " ) {
200
+ test(" Not expected type - SimplifyConditionalsInPredicate " ) {
193
201
val e = intercept[AnalysisException ] {
194
202
testFilter(originalCond = Literal (null , IntegerType ), expectedCond = FalseLiteral )
195
203
}.getMessage
0 commit comments