Uh oh!
There was an error while loading. Please reload this page.
[SPARK-11164] [SQL] Add InSet pushdown filter back for Parquet - #10278
[SPARK-11164] [SQL] Add InSet pushdown filter back for Parquet#10278gatorsmile wants to merge 25 commits into
Conversation
gatorsmile
commented
Dec 12, 2015
After reading the other push-down PR, I think it also needs a review from @liancheng . Welcome any comment! Thanks! |
SparkQA
commented
Dec 12, 2015
Test build #47615 has finished for PR 10278 at commit
|
SparkQA
commented
Dec 12, 2015
Test build #47616 has finished for PR 10278 at commit
|
marmbrus
commented
Dec 12, 2015
Do you have a test case that actually shows a wrong answer being computed? |
gatorsmile
commented
Dec 12, 2015
This only happens in 1.5. Do you need me to write a test case for 1.5? |
marmbrus
commented
Dec 12, 2015
Any bug fix should have a regression test. We could always change the optimizer in a way that does not hide this bug anymore. |
gatorsmile
commented
Dec 12, 2015
Ok, will make a try to force it. Thanks! |
marmbrus
commented
Dec 13, 2015
Its fine if the test only fails on 1.5 |
gatorsmile
commented
Dec 13, 2015
Great! : ) Let me also post the test case I did in the latest 1.5. Without my fix, the first call of show() did not return the row (2, 0). Feel free to let me know if you want me to deliver the following test case. withSQLConf(SQLConf.PARQUET_FILTER_PUSHDOWN_ENABLED.key ->"true") {
withTempPath { dir =>valpath=s"${dir.getCanonicalPath}/table1"
(1 to 5).map(i => (i, (i%2).toString)).toDF("a", "b").write.parquet(path)
valdf= sqlContext.read.parquet(path).where("not (a = 2 and b in ('1'))")
df.show()
valdf1= sqlContext.read.parquet(path).where("not (a = 2) or not(b in ('1'))")
df1.show()
}
} |
gatorsmile
commented
Dec 13, 2015
I might find another bug in Parquet pushdown. Will submit the fix later when I can confirm it. |
SparkQA
commented
Dec 13, 2015
Test build #47618 has finished for PR 10278 at commit
|
liancheng
commented
Dec 17, 2015
@gatorsmile Sorry for the late reply and thanks for the nice catch! The For the
One benefit of CNF is that it enables more filter push-down opportunities. Since we don't have existential / universal quantifier in our predicates, I think CNF conversion in Spark SQL can be as simple as keeping pushing objectCNFConversionextendsRule[LogicalPlan] {
overridedefapply(plan: LogicalPlan):LogicalPlan= plan transform {
casefilter: Filter=>importorg.apache.spark.sql.catalyst.dsl.expressions._
filter.copy(condition = filter.condition.transform {
caseNot(x Or y) =>!x &&!y
caseNot(x And y) =>!x ||!y
case (x And y) Or z => (x || z) && (y || z)
case x Or (y And z) => (x || y) && (x || z)
})
}
}(Notice that this version doesn't handle common expression elimination.) That said, the @rxin@marmbrus Not super confident about the CNF conversion conclusion above, please correct me if I'm wrong. |
Not is included in Parquet filter pushdownNot is included in Parquet filter pushdowngatorsmile
commented
Dec 17, 2015
Thank you for your detailed explanation! @liancheng I have the same opinion as @marmbrus . We should include CNF conversion into our optimizer. Some RDBMS systems do it in the phase of query rewriting. Below is my 2 cents about CNF. Generally, CNF conversion is an important concept in query optimization, especially when we support indexing in Spark. When (multi-attribute) indexes exist over some subset of conjucts, we can employ these indexes to improve the selectivity. Thanks! |
There was a problem hiding this comment.
Looks like this is the real problem. It is not safe to just push one side at here. This is the place where we drop that In because createFilter(schema, In(...)) returns None.
There was a problem hiding this comment.
@gatorsmile I am also going to try to have a fix. We can later see which one is a more suitable.
There was a problem hiding this comment.
Glad to see your fix. : ) Thank you!
SparkQA
commented
Dec 17, 2015
Test build #47939 has finished for PR 10278 at commit
|
gatorsmile
commented
Dec 18, 2015
@yhuai@liancheng Regarding this PR, should I keep it open? This PR also has another fix that can push down the filter |
yhuai
commented
Dec 18, 2015
You can change it to just handle |
gatorsmile
commented
Dec 18, 2015
After reading the contents, that PR was closed due to another issue of String filters in the same PR. Please correct me if my understanding is wrong. @liancheng Do you want to deliver this by submitting another PR, @viirya ? Either is fine for me. Thanks! |
# Conflicts: # sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetFilterSuite.scala
# Conflicts: # sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetFilterSuite.scala
SparkQA
commented
Dec 19, 2015
Test build #48036 has finished for PR 10278 at commit
|
gatorsmile
commented
Dec 19, 2015
retest this please |
SparkQA
commented
Dec 19, 2015
Test build #48045 has finished for PR 10278 at commit
|
liancheng
commented
Dec 19, 2015
@gatersmile Yeah, you're right. #8956 initially aimed to fix other issues, and also included the fix for BTW, it's almost always strictly better to open small PRs that contains ONLY a single change than bigger ones that contains multiple changes. The former are much easier to review and get merged. (One liner PRs are super welcomed!) |
gatorsmile
commented
Dec 19, 2015
Thank you for your suggestions! @liancheng : ) Next time, I will not mix multiple fixes in the same PR. |
Not is included in Parquet filter pushdowngatorsmile
commented
Dec 22, 2015
liancheng
commented
Dec 23, 2015
@gatorsmile Could you please update the PR description? |
gatorsmile
commented
Dec 23, 2015
@liancheng Done. : ) |
liancheng
commented
Dec 23, 2015
Thanks! I'm merging this to master, and will attribute this one to @viirya. |
gatorsmile
commented
Dec 23, 2015
Thank you! |
viirya
commented
Dec 23, 2015
Thanks @gatorsmile@liancheng |
When the filter is
"b in ('1', '2')", the filter is not pushed down to Parquet. Thanks!