Uh oh!
There was an error while loading. Please reload this page.
[SPARK-16683][SQL] Repeated joins to same table can leak attributes via partitioning giving incorrect results - #18697
[SPARK-16683][SQL] Repeated joins to same table can leak attributes via partitioning giving incorrect results#18697aray wants to merge 5 commits into
Conversation
aray
commented
Jul 21, 2017
Plan for the example query before the patch (with partitioning as suffix): and after the patch: Note there is now an |
SparkQA
commented
Jul 21, 2017
Test build #79822 has finished for PR 18697 at commit
|
SparkQA
commented
Jul 21, 2017
Test build #79823 has finished for PR 18697 at commit
|
aray
commented
Jul 21, 2017
retest this please |
SparkQA
commented
Jul 21, 2017
Test build #79836 has finished for PR 18697 at commit
|
aray
commented
Jul 25, 2017
ping @rxin can someone look at this correctness fix? |
rxin
commented
Jul 25, 2017
gatorsmile
commented
Jul 31, 2017
I will review this next week. |
viirya
commented
Jul 31, 2017
I'd like to reword the problem description as the current one looks obscure to me. Currently we don't care if the output partitioning of an operator contains the attributes not in the output. For example, the output partitioning of I've noticed this and raised questions about it before. The answer I got is this doesn't do any harm so we don't fix it before. However, this PR finds a case it possibly causes problem. Like: |
| override def verboseStringWithSuffix: String = { | ||
| s"$verboseString $outputPartitioning" | ||
| } |
There was a problem hiding this comment.
Except for debugging this, do we really need to print out output partitioning always?
There was a problem hiding this comment.
This doesn't change anything that is in common use, one has to do plan.treeString(verbose = true, addSuffix = true) to get it. I would argue for keeping it for any future debugging.
| base.createOrReplaceTempView("base") | ||
| val dist1 = spark.sql(""" | ||
| SELECT parent level1 |
| // dist1.count() // or put a count here | ||
| val dist2 = spark.sql(""" | ||
| SELECT parent level2 |
A different view to this problem is, in the following part of query plan: At the top If we change I think this is also an alternative solution. @aray What do you think? Instead of replacing original output partitioning with |
aray
commented
Jul 31, 2017
@viirya We could certainly make that improvement. I believe it would be a fairly trivial change to this PR if we were just considering expressions that have the same canonical representation. However for reasons that are not clear to me an alias does not automatically have the same canonical representation as the |
SparkQA
commented
Jul 31, 2017
Test build #80080 has finished for PR 18697 at commit
|
…6683 # Conflicts: # sql/core/src/test/scala/org/apache/spark/sql/JoinSuite.scala
SparkQA
commented
Aug 31, 2017
Test build #81284 has finished for PR 18697 at commit
|
| * attributes. If the partitioning is an [[Expression]] then the attributes that it depends on | ||
| * must be in the outputSet otherwise the attribute leaks. | ||
| */ | ||
| def restrict(outputSet: AttributeSet): Partitioning = this match { |
There was a problem hiding this comment.
We are refactoring the concept of distribution and partitioning in the PR #19080
Could you provide your inputs in that PR first? Thanks!
SparkQA
commented
Aug 31, 2017
Test build #81286 has finished for PR 18697 at commit
|
cloud-fan
commented
Sep 1, 2017
shouldn't we fix |
viirya
commented
Sep 1, 2017
If we have correct |
maropu
commented
Jul 23, 2018
@aray Can you close this for now because it's not active for a long time? (I'm not sure the current master still has this issue..., so you should check it first) |
HyukjinKwon
commented
Nov 11, 2018
Let't close this then. |
Closesapache#21766Closesapache#21679Closesapache#21161Closesapache#20846Closesapache#19434Closesapache#18080Closesapache#17648Closesapache#17169 Add: Closesapache#22813Closesapache#21994Closesapache#22005Closesapache#22463 Add: Closesapache#15899 Add: Closesapache#22539Closesapache#21868Closesapache#21514Closesapache#21402Closesapache#21322Closesapache#21257Closesapache#20163Closesapache#19691Closesapache#18697Closesapache#18636Closesapache#17176Closesapache#23001 from wangyum/CloseStalePRs. Authored-by: Yuming Wang <yumwang@ebay.com> Signed-off-by: hyukjinkwon <gurwls223@apache.org>
What changes were proposed in this pull request?
In some complex queries where the same table is joined multiple times interleaved with aggregation we can get conflicting attributes that leak via partitionings leading to wrong results because shuffles are not inserted. See
JoinSuitediff for example. This patch adds a method toPartitioningthat restricts it to a given set of output attributes. This method is then called by operators that generally maintain their input distribution but output only a subset of the inputs.How was this patch tested?
Unit test based on example code from JIRA and additional unit testing of new method.