-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #239 from osopardo1/235-add-delta-data-skipping
Add Delta Data Skipping on Staging Area
- Loading branch information
Showing
6 changed files
with
164 additions
and
85 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package io.qbeast | ||
|
||
import io.qbeast.spark.QbeastIntegrationTestSpec | ||
import io.qbeast.spark.delta.OTreeIndex | ||
import io.qbeast.spark.internal.expressions.QbeastMurmur3Hash | ||
import org.apache.spark.sql.DataFrame | ||
import org.apache.spark.sql.execution.FileSourceScanExec | ||
|
||
object TestUtils extends QbeastIntegrationTestSpec { | ||
|
||
def checkLogicalFilterPushdown(sqlFilters: Seq[String], query: DataFrame): Unit = { | ||
val leaves = query.queryExecution.sparkPlan.collectLeaves() | ||
|
||
val dataFilters = leaves | ||
.collectFirst { | ||
case f: FileSourceScanExec if f.relation.location.isInstanceOf[OTreeIndex] => | ||
f.dataFilters.filterNot(_.isInstanceOf[QbeastMurmur3Hash]) | ||
} | ||
.getOrElse(Seq.empty) | ||
|
||
val dataFiltersSql = dataFilters.map(_.sql) | ||
sqlFilters.foreach(filter => dataFiltersSql should contain(filter)) | ||
} | ||
|
||
def checkFiltersArePushedDown(query: DataFrame): Unit = { | ||
val leaves = | ||
query.queryExecution.executedPlan.collectLeaves().filter(_.isInstanceOf[FileSourceScanExec]) | ||
|
||
leaves should not be empty | ||
|
||
leaves.exists(p => | ||
p | ||
.asInstanceOf[FileSourceScanExec] | ||
.relation | ||
.location | ||
.isInstanceOf[OTreeIndex]) shouldBe true | ||
|
||
leaves | ||
.foreach { | ||
case f: FileSourceScanExec if f.relation.location.isInstanceOf[OTreeIndex] => | ||
f.dataFilters.nonEmpty shouldBe true | ||
} | ||
} | ||
|
||
def checkFileFiltering(query: DataFrame): Unit = { | ||
val leaves = | ||
query.queryExecution.executedPlan.collectLeaves().filter(_.isInstanceOf[FileSourceScanExec]) | ||
|
||
leaves should not be empty | ||
|
||
leaves.exists(p => | ||
p | ||
.asInstanceOf[FileSourceScanExec] | ||
.relation | ||
.location | ||
.isInstanceOf[OTreeIndex]) shouldBe true | ||
|
||
leaves | ||
.foreach { | ||
case f: FileSourceScanExec if f.relation.location.isInstanceOf[OTreeIndex] => | ||
val index = f.relation.location | ||
val matchingFiles = | ||
index.listFiles(f.partitionFilters, f.dataFilters).flatMap(_.files) | ||
val allFiles = index.listFiles(Seq.empty, Seq.empty).flatMap(_.files) | ||
matchingFiles.length shouldBe <(allFiles.length) | ||
} | ||
|
||
} | ||
|
||
} |
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
27 changes: 2 additions & 25 deletions
27
src/test/scala/io/qbeast/spark/utils/QbeastSamplingTest.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