[GitHub] [spark] gengliangwang commented on a change in pull request #29075: [SPARK-32284][SQL] Avoid expanding too many CNF predicates in partition pruning
gengliangwang commented on a change in pull request #29075: URL: https://github.com/apache/spark/pull/29075#discussion_r453409529 ## File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PruneFileSourcePartitions.scala ## @@ -53,11 +53,17 @@ private[sql] object PruneFileSourcePartitions val partitionColumns = relation.resolve(partitionSchema, sparkSession.sessionState.analyzer.resolver) val partitionSet = AttributeSet(partitionColumns) -val (partitionFilters, dataFilters) = normalizedFilters.partition(f => +val (partitionFilters, remainingFilters) = normalizedFilters.partition(f => f.references.subsetOf(partitionSet) ) -(ExpressionSet(partitionFilters), dataFilters) +// Try extracting more convertible partition filters from the remaining filters by converting +// them into CNF. +val remainingFilterInCnf = remainingFilters.flatMap(CNFConversion) +val extraPartitionFilters = + remainingFilterInCnf.filter(f => f.references.subsetOf(partitionSet)) + +(ExpressionSet(partitionFilters ++ extraPartitionFilters), remainingFilters) Review comment: In that way, `otherFilters` can be very long, which leads to a longer codegen... I am avoiding that on purpose. Let me add comment here. 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: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] gengliangwang commented on a change in pull request #29075: [SPARK-32284][SQL] Avoid expanding too many CNF predicates in partition pruning
gengliangwang commented on a change in pull request #29075: URL: https://github.com/apache/spark/pull/29075#discussion_r453408669 ## File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/PruneHiveTablePartitions.scala ## @@ -54,9 +55,15 @@ private[sql] class PruneHiveTablePartitions(session: SparkSession) val normalizedFilters = DataSourceStrategy.normalizeExprs( filters.filter(f => f.deterministic && !SubqueryExpression.hasSubquery(f)), relation.output) val partitionColumnSet = AttributeSet(relation.partitionCols) -ExpressionSet(normalizedFilters.filter { f => +val (partitionFilters, remainingFilters) = normalizedFilters.partition { f => !f.references.isEmpty && f.references.subsetOf(partitionColumnSet) -}) +} +// Try extracting more convertible partition filters from the remaining filters by converting +// them into CNF. +val remainingFilterInCnf = remainingFilters.flatMap(CNFConversion) +val extraPartitionFilters = remainingFilterInCnf.filter(f => + !f.references.isEmpty && f.references.subsetOf(partitionColumnSet)) +ExpressionSet(partitionFilters ++ extraPartitionFilters) Review comment: The `filters` here is already processed with `splitConjunctivePredicates` in `PhysicalOperation.unapply`. That's why the original code before #28805 doesn't call `splitConjunctivePredicates` either. 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: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org