-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-24934][SQL] Explicitly whitelist supported types in upper/lower bounds for in-memory partition pruning #21882
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ package org.apache.spark.sql.execution.columnar | |
import org.scalatest.BeforeAndAfterEach | ||
|
||
import org.apache.spark.SparkFunSuite | ||
import org.apache.spark.sql.DataFrame | ||
import org.apache.spark.sql.internal.SQLConf | ||
import org.apache.spark.sql.test.SharedSQLContext | ||
import org.apache.spark.sql.test.SQLTestData._ | ||
|
@@ -35,6 +36,12 @@ class PartitionBatchPruningSuite | |
private lazy val originalColumnBatchSize = spark.conf.get(SQLConf.COLUMN_BATCH_SIZE) | ||
private lazy val originalInMemoryPartitionPruning = | ||
spark.conf.get(SQLConf.IN_MEMORY_PARTITION_PRUNING) | ||
private val testArrayData = (1 to 100).map { key => | ||
Tuple1(Array.fill(key)(key)) | ||
} | ||
private val testBinaryData = (1 to 100).map { key => | ||
Tuple1(Array.fill(key)(key.toByte)) | ||
} | ||
|
||
override protected def beforeAll(): Unit = { | ||
super.beforeAll() | ||
|
@@ -71,12 +78,22 @@ class PartitionBatchPruningSuite | |
}, 5).toDF() | ||
pruningStringData.createOrReplaceTempView("pruningStringData") | ||
spark.catalog.cacheTable("pruningStringData") | ||
|
||
val pruningArrayData = sparkContext.makeRDD(testArrayData, 5).toDF() | ||
pruningArrayData.createOrReplaceTempView("pruningArrayData") | ||
spark.catalog.cacheTable("pruningArrayData") | ||
|
||
val pruningBinaryData = sparkContext.makeRDD(testBinaryData, 5).toDF() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
pruningBinaryData.createOrReplaceTempView("pruningBinaryData") | ||
spark.catalog.cacheTable("pruningBinaryData") | ||
} | ||
|
||
override protected def afterEach(): Unit = { | ||
try { | ||
spark.catalog.uncacheTable("pruningData") | ||
spark.catalog.uncacheTable("pruningStringData") | ||
spark.catalog.uncacheTable("pruningArrayData") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uncache the |
||
spark.catalog.uncacheTable("pruningBinaryData") | ||
} finally { | ||
super.afterEach() | ||
} | ||
|
@@ -95,6 +112,14 @@ class PartitionBatchPruningSuite | |
checkBatchPruning("SELECT key FROM pruningData WHERE 11 >= key", 1, 2)(1 to 11) | ||
checkBatchPruning("SELECT key FROM pruningData WHERE 88 < key", 1, 2)(89 to 100) | ||
checkBatchPruning("SELECT key FROM pruningData WHERE 89 <= key", 1, 2)(89 to 100) | ||
// Do not filter on array type | ||
checkBatchPruning("SELECT _1 FROM pruningArrayData WHERE _1 = array(1)", 5, 10)(Seq(Array(1))) | ||
checkBatchPruning("SELECT _1 FROM pruningArrayData WHERE _1 <= array(1)", 5, 10)(Seq(Array(1))) | ||
checkBatchPruning("SELECT _1 FROM pruningArrayData WHERE _1 >= array(1)", 5, 10)( | ||
testArrayData.map(_._1)) | ||
// Do not filter on binary type | ||
checkBatchPruning( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before this change, |
||
"SELECT _1 FROM pruningBinaryData WHERE _1 == binary(chr(1))", 5, 10)(Seq(Array(1.toByte))) | ||
|
||
// IS NULL | ||
checkBatchPruning("SELECT key FROM pruningData WHERE value IS NULL", 5, 5) { | ||
|
@@ -131,6 +156,9 @@ class PartitionBatchPruningSuite | |
checkBatchPruning( | ||
"SELECT CAST(s AS INT) FROM pruningStringData WHERE s IN ('99', '150', '201')", 1, 1)( | ||
Seq(150)) | ||
// Do not filter on array type | ||
checkBatchPruning("SELECT _1 FROM pruningArrayData WHERE _1 IN (array(1), array(2, 2))", 5, 10)( | ||
Seq(Array(1), Array(2, 2))) | ||
|
||
// With unsupported `InSet` predicate | ||
{ | ||
|
@@ -161,7 +189,7 @@ class PartitionBatchPruningSuite | |
query: String, | ||
expectedReadPartitions: Int, | ||
expectedReadBatches: Int)( | ||
expectedQueryResult: => Seq[Int]): Unit = { | ||
expectedQueryResult: => Seq[Any]): Unit = { | ||
|
||
test(query) { | ||
val df = sql(query) | ||
|
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.
can we also add test for binary type?
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.
Will add late tonight or tomorrow