-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-44493][SQL] Translate catalyst expression into partial datasource filter #43769
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
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 |
|---|---|---|
|
|
@@ -77,7 +77,7 @@ abstract class FileScanBuilder( | |
| this.dataFilters = dataFilters | ||
| val translatedFilters = mutable.ArrayBuffer.empty[sources.Filter] | ||
| for (filterExpr <- dataFilters) { | ||
| val translated = DataSourceStrategy.translateFilter(filterExpr, true) | ||
| val translated = DataSourceStrategy.translateFilter(filterExpr, true, true) | ||
|
||
| if (translated.nonEmpty) { | ||
| translatedFilters += translated.get | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,10 +25,12 @@ import scala.jdk.CollectionConverters._ | |
| import org.scalatest.Assertions | ||
|
|
||
| import org.apache.spark.sql.catalyst.ExtendedAnalysisException | ||
| import org.apache.spark.sql.catalyst.expressions.{Expression, ExpressionSet} | ||
| import org.apache.spark.sql.catalyst.plans._ | ||
| import org.apache.spark.sql.catalyst.util._ | ||
| import org.apache.spark.sql.execution.SQLExecution | ||
| import org.apache.spark.sql.execution.columnar.InMemoryRelation | ||
| import org.apache.spark.sql.functions.expr | ||
| import org.apache.spark.storage.StorageLevel | ||
| import org.apache.spark.util.ArrayImplicits._ | ||
|
|
||
|
|
@@ -252,6 +254,23 @@ abstract class QueryTest extends PlanTest { | |
| Pattern.quote( | ||
| s"${cs.getClassName}.${cs.getMethodName}(${cs.getFileName}:${cs.getLineNumber + lines})") | ||
| } | ||
|
|
||
| /** | ||
| * Returns a set with all the filters present in the physical plan. | ||
| */ | ||
| def getPhysicalFilters(df: DataFrame): ExpressionSet = { | ||
| ExpressionSet( | ||
| df.queryExecution.executedPlan.collect { | ||
| case execution.FilterExec(f, _) => splitConjunctivePredicates(f) | ||
| }.flatten) | ||
| } | ||
|
|
||
| /** | ||
| * Returns a resolved expression for `str` in the context of `df`. | ||
| */ | ||
| def resolve(df: DataFrame, str: String): Expression = { | ||
| df.select(expr(str)).queryExecution.analyzed.expressions.head.children.head | ||
| } | ||
|
Comment on lines
+258
to
+273
Member
Author
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. Moved from FileSourceStrategySuite.scala |
||
| } | ||
|
|
||
| object QueryTest extends Assertions { | ||
|
|
||
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.
cc @dongjoon-hyun @viirya