Github user gatorsmile commented on the pull request:

    https://github.com/apache/spark/pull/9548#issuecomment-155912100
  
    @cloud-fan So far, we do not have an easy fix, but I believe we should 
never return a wrong result for self join. 
    
    Let me post the test case I added. This test case will return an incorrect 
result without any exception:
    ```scala
    test("[SPARK-10838] self join - conflicting attributes in condition - 
incorrect result 2") {
       val df1 = Seq((1, 3), (2, 1)).toDF("keyCol1", "keyCol2")
       val df2 = Seq((1, 4), (2, 1)).toDF("keyCol1", "keyCol3")
       val df3 = df1.join(df2, df1("keyCol1") === 
df2("keyCol1")).select(df1("keyCol1"), $"keyCol3")
       checkAnswer(
         df3.join(df1, df3("keyCol3") === df1("keyCol1") && df1("keyCol1") === 
df3("keyCol3")),
         Row(2, 1, 1, 3) :: Nil)
     }
    ```
    
    Before resolving this problem, what we can do it is to detect it and let 
customers use the workaround you mentioned. The detection condition is simple. 
The incorrect result could happen when the conflicting attributes contain the 
`AttributeReference` that appear in join condition. 
    
    Do you agree @cloud-fan @marmbrus ?
    
    If OK, I will submit another PR for detecting it and issuing an exception 
with a meaningful message to users. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to