-
Notifications
You must be signed in to change notification settings - Fork 28.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-28169][SQL] Convert scan predicate condition to CNF #28805
Closed
AngersZhuuuu
wants to merge
28
commits into
apache:master
from
AngersZhuuuu:cnf-for-partition-pruning
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3356bac
WIP
AngersZhuuuu 346a1b4
save
AngersZhuuuu 250c7b3
Update HiveTableScanSuite.scala
AngersZhuuuu 15d62be
save
AngersZhuuuu 39e85ad
Merge branch 'master' into cnf-for-partition-pruning
AngersZhuuuu d8f7c9e
save
AngersZhuuuu 8856453
Update SQLConf.scala
AngersZhuuuu 697a3a9
Update HiveTableScanSuite.scala
AngersZhuuuu 7e8319e
Update predicates.scala
AngersZhuuuu 3734866
empty safe
AngersZhuuuu b253af3
save
AngersZhuuuu 478a7a8
fix bug
AngersZhuuuu 603660b
save
AngersZhuuuu 69f1763
wip
AngersZhuuuu 2f576fa
fix return bug
AngersZhuuuu e71c45c
Merge branch 'master' into cnf-for-partition-pruning
AngersZhuuuu 94609c8
Don‘t add new rule
AngersZhuuuu 326fb49
Update PruneFileSourcePartitions.scala
AngersZhuuuu 9322ae6
follow comment
AngersZhuuuu 4a2adcd
Update PruneFileSourcePartitionsSuite.scala
AngersZhuuuu 0e2579d
move test case
AngersZhuuuu 270324e
Update HiveTableScanSuite.scala
AngersZhuuuu 219f200
follow comment
AngersZhuuuu f21cf43
follow comment
AngersZhuuuu 35b5813
follow comment
AngersZhuuuu 3df019a
Update predicates.scala
AngersZhuuuu 1b8466e
follow comment
AngersZhuuuu e2777c9
follow comment
AngersZhuuuu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/PrunePartitionSuiteBase.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.sql.hive.execution | ||
|
||
import org.apache.spark.sql.QueryTest | ||
import org.apache.spark.sql.execution.SparkPlan | ||
import org.apache.spark.sql.hive.test.TestHiveSingleton | ||
import org.apache.spark.sql.test.SQLTestUtils | ||
|
||
abstract class PrunePartitionSuiteBase extends QueryTest with SQLTestUtils with TestHiveSingleton { | ||
|
||
protected def format: String | ||
|
||
test("SPARK-28169: Convert scan predicate condition to CNF") { | ||
withTempView("temp") { | ||
withTable("t") { | ||
sql( | ||
s""" | ||
|CREATE TABLE t(i INT, p STRING) | ||
|USING $format | ||
|PARTITIONED BY (p)""".stripMargin) | ||
|
||
spark.range(0, 1000, 1).selectExpr("id as col") | ||
.createOrReplaceTempView("temp") | ||
cloud-fan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
for (part <- Seq(1, 2, 3, 4)) { | ||
sql( | ||
s""" | ||
|INSERT OVERWRITE TABLE t PARTITION (p='$part') | ||
|SELECT col FROM temp""".stripMargin) | ||
} | ||
|
||
assertPrunedPartitions( | ||
"SELECT * FROM t WHERE p = '1' OR (p = '2' AND i = 1)", 2) | ||
assertPrunedPartitions( | ||
"SELECT * FROM t WHERE (p = '1' AND i = 2) OR (i = 1 OR p = '2')", 4) | ||
assertPrunedPartitions( | ||
"SELECT * FROM t WHERE (p = '1' AND i = 2) OR (p = '3' AND i = 3 )", 2) | ||
assertPrunedPartitions( | ||
"SELECT * FROM t WHERE (p = '1' AND i = 2) OR (p = '2' OR p = '3')", 3) | ||
assertPrunedPartitions( | ||
"SELECT * FROM t", 4) | ||
assertPrunedPartitions( | ||
"SELECT * FROM t WHERE p = '1' AND i = 2", 1) | ||
assertPrunedPartitions( | ||
""" | ||
|SELECT i, COUNT(1) FROM ( | ||
|SELECT * FROM t WHERE p = '1' OR (p = '2' AND i = 1) | ||
|) tmp GROUP BY i | ||
""".stripMargin, 2) | ||
} | ||
} | ||
} | ||
|
||
protected def assertPrunedPartitions(query: String, expected: Long): Unit = { | ||
val plan = sql(query).queryExecution.sparkPlan | ||
assert(getScanExecPartitionSize(plan) == expected) | ||
} | ||
|
||
protected def getScanExecPartitionSize(plan: SparkPlan): Long | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit format: