GitHub user gengliangwang opened a pull request:

    https://github.com/apache/spark/pull/20278

    [SPARK-23079][SQL]Fix query constraints propagation with aliases 

    ## What changes were proposed in this pull request?
    
    Previously, PR #19201 fix the problem of non-converging constraints.
    After that PR #19149 improve the loop and constraints is inferred only once.
    So the problem of non-converging constraints is gone.
    
    However, the case below will fail.
    
    ```
    
    spark.range(5).write.saveAsTable("t")
    val t = spark.read.table("t")
    val left = t.withColumn("xid", $"id" + lit(1)).as("x")
    val right = t.withColumnRenamed("id", "xid").as("y")
    val df = left.join(right, "xid").filter("id = 3").toDF()
    checkAnswer(df, Row(4, 3))
    
    ```
    
    Because `aliasMap` replace all the aliased child. See the test case in PR 
for details.
    
    This PR is to fix this bug by removing useless code for preventing 
non-converging constraints.
    It can be also fixed with #20270, but this is much simpler and clean up the 
code.
     
    
    ## How was this patch tested?
    
    Unit test


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gengliangwang/spark FixConstraintSimple

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/20278.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #20278
    
----
commit c02d9b4bdccafcdf4008dcdd4c2ad9509c9acd96
Author: Wang Gengliang <ltnwgl@...>
Date:   2018-01-16T17:05:28Z

    Simple fix

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to