@@ -208,43 +208,48 @@ trait PredicateHelper extends Logging {
208
208
*/
209
209
protected def convertibleFilter (
210
210
condition : Expression ,
211
- outputSet : AttributeSet ): Option [Expression ] = condition match {
212
- case And (left, right) =>
213
- val leftResultOptional = convertibleFilter(left, outputSet)
214
- val rightResultOptional = convertibleFilter(right, outputSet)
215
- (leftResultOptional, rightResultOptional) match {
216
- case (Some (leftResult), Some (rightResult)) => Some (And (leftResult, rightResult))
217
- case (Some (leftResult), None ) => Some (leftResult)
218
- case (None , Some (rightResult)) => Some (rightResult)
219
- case _ => None
220
- }
211
+ outputSet : AttributeSet ): Option [Expression ] = {
212
+ println(" condition: " + condition)
213
+ val ret = condition match {
214
+ case And (left, right) =>
215
+ val leftResultOptional = convertibleFilter(left, outputSet)
216
+ val rightResultOptional = convertibleFilter(right, outputSet)
217
+ (leftResultOptional, rightResultOptional) match {
218
+ case (Some (leftResult), Some (rightResult)) => Some (And (leftResult, rightResult))
219
+ case (Some (leftResult), None ) => Some (leftResult)
220
+ case (None , Some (rightResult)) => Some (rightResult)
221
+ case _ => None
222
+ }
221
223
222
- // The Or predicate is convertible when both of its children can be pushed down.
223
- // That is to say, if one/both of the children can be partially pushed down, the Or
224
- // predicate can be partially pushed down as well.
225
- //
226
- // Here is an example used to explain the reason.
227
- // Let's say we have
228
- // (a1 AND a2) OR (b1 AND b2),
229
- // a1 and b1 is convertible, while a2 and b2 is not.
230
- // The predicate can be converted as
231
- // (a1 OR b1) AND (a1 OR b2) AND (a2 OR b1) AND (a2 OR b2)
232
- // As per the logical in And predicate, we can push down (a1 OR b1).
233
- case Or (left, right) =>
234
- for {
235
- lhs <- convertibleFilter(left, outputSet)
236
- rhs <- convertibleFilter(right, outputSet)
237
- } yield Or (lhs, rhs)
238
-
239
- // Here we assume all the `Not` operators is already below all the `And` and `Or` operators
240
- // after the optimization rule `BooleanSimplification`, so that we don't need to handle the
241
- // `Not` operators here.
242
- case other =>
243
- if (other.references.subsetOf(outputSet)) {
244
- Some (other)
245
- } else {
246
- None
247
- }
224
+ // The Or predicate is convertible when both of its children can be pushed down.
225
+ // That is to say, if one/both of the children can be partially pushed down, the Or
226
+ // predicate can be partially pushed down as well.
227
+ //
228
+ // Here is an example used to explain the reason.
229
+ // Let's say we have
230
+ // (a1 AND a2) OR (b1 AND b2),
231
+ // a1 and b1 is convertible, while a2 and b2 is not.
232
+ // The predicate can be converted as
233
+ // (a1 OR b1) AND (a1 OR b2) AND (a2 OR b1) AND (a2 OR b2)
234
+ // As per the logical in And predicate, we can push down (a1 OR b1).
235
+ case Or (left, right) =>
236
+ for {
237
+ lhs <- convertibleFilter(left, outputSet)
238
+ rhs <- convertibleFilter(right, outputSet)
239
+ } yield Or (lhs, rhs)
240
+
241
+ // Here we assume all the `Not` operators is already below all the `And` and `Or` operators
242
+ // after the optimization rule `BooleanSimplification`, so that we don't need to handle the
243
+ // `Not` operators here.
244
+ case other =>
245
+ if (other.references.subsetOf(outputSet)) {
246
+ Some (other)
247
+ } else {
248
+ None
249
+ }
250
+ }
251
+ println(" ret: " + ret)
252
+ ret
248
253
}
249
254
}
250
255
0 commit comments