GitHub user cloud-fan opened a pull request:

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

    [SPARK-XXXX][SQL] Can't add subquery to an operator with same-name outputs 
while generate SQL string

    ## What changes were proposed in this pull request?
    
    This PR tries to solve a fundamental issue in the `SQLBuilder`. When we 
want to turn a logical plan into SQL string and put it after FROM clause, we 
need to wrap it with a sub-query. However, a logical plan is allowed to have 
same-name outputs with different qualifiers(e.g. the `Join` operator), and this 
kind of plan can't be put under a subquery as we will erase and assign a new 
qualifier to all outputs and make it impossible to distinguish same-name 
outputs.
    
    To solve this problem, this PR renames all attributes with globally unique 
names(using exprId), so that we don't need qualifiers to resolve ambiguity 
anymore.
    
    ## How was this patch tested?
    
    existing tests and new tests in LogicalPlanToSQLSuite.

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

    $ git pull https://github.com/cloud-fan/spark gensql

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

    https://github.com/apache/spark/pull/11658.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 #11658
    
----
commit f4b1ae8b30c2a572d4f44cd68b66c224aeee553b
Author: Wenchen Fan <wenc...@databricks.com>
Date:   2016-03-11T06:29:45Z

    tmp

commit 198b406a643d908483408ec6ccea26ffdc464aa9
Author: Wenchen Fan <wenc...@databricks.com>
Date:   2016-03-11T14:35:50Z

    assign globally unique names to all attributes to avoid ambiguity

----


---
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