You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/07/01 01:16:04 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #24973: [SPARK-28169] Fix Partition table partition PushDown failed by "OR" expression

cloud-fan commented on a change in pull request #24973: [SPARK-28169] Fix Partition table partition  PushDown failed by "OR" expression 
URL: https://github.com/apache/spark/pull/24973#discussion_r298859157
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/planning/patterns.scala
 ##########
 @@ -310,3 +310,97 @@ object PhysicalWindow {
     case _ => None
   }
 }
+
+/**
+ * Extract partition push down condition from ExpressionSet
+ * Since origin judge condition is
+ *    {
+ *       !expression.references.isEmpty &&
+ *             expression.references.subsetOf(partitionKeyIds)
+ *    }
+ *
+ *  This can only push down simple condition expression.
+ *  Such as table:
+ *   CREATE TABLE DEFAULT.PARTITION_TABLE(
+ *   A STRING,
+ *   B STRING)
+ *   PARTITIONED BY(DT STRING)
+ *
+ * With SQL:
+ *   SELECT A, B
+ *   FROM DEFAULT.PARTITION_TABLE
+ *   WHERE DT = 20190601 OR (DT = 20190602 AND C = "TEST")
+ *
+ * Where condition "DT = 20190601 OR (DT = 20190602 AND C = "TEST")"
+ * can't be pushed down since it's reference is not subsetOf partition cols
+ * [[ExtractPartitionPredicates]] is to help extract hided partition logic in Or expression.
+ * It will return Or( DT = 20190601 , DT = 20190602 ) for partition push down.
+ *
+ * For special Or condition such as :
+ * SELECT A, B
+ * FROM DEFAULT.PARTITION_TABLE
+ * WHERE DT = 20190601 OR (DT = 20190602 OR C = "TEST")
+ *
+ * It won't think it's a validate push down condition and return a empty expression set.
+ *
+ */
+object ExtractPartitionPredicates extends Logging {
+
+  private type ReturnType = Seq[Expression]
 
 Review comment:
   We don't need this type alias as `Seq[Expression]` is short.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org