You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by viirya <gi...@git.apache.org> on 2016/06/03 08:25:07 UTC

[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

GitHub user viirya opened a pull request:

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

    [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from DataFrameWriter

    ## What changes were proposed in this pull request?
    
    This patch moves some codes in `DataFrameWriter.insertInto` that belongs to `Analyzer`.
    
    ## How was this patch tested?
    Existing tests.
    
    


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

    $ git pull https://github.com/viirya/spark-1 move-analyzer-stuff

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

    https://github.com/apache/spark/pull/13496.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 #13496
    
----
commit 83b2e6e066611b972e1dddb0b3eb1ae3f8389753
Author: Liang-Chi Hsieh <si...@tw.ibm.com>
Date:   2016-06-03T08:20:44Z

    Move Analyzer stuff to Analyzer from DataFrameWriter.

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66345073
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val inputWhenPartsNonEmpty = if (parts.nonEmpty) {
    --- End diff --
    
    maybe just `input`? The else branch doesn't return a `inputWhenPartsNonEmpty`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/60206/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66725290
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val input = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          Project(inputDataCols ++ inputPartCols, child)
    +        } else {
    +          child
    +        }
    --- End diff --
    
    do you mean we should not do this?



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66344535
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala ---
    @@ -1042,7 +1042,7 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
             .queryExecution.analyzed
         }
     
    -    assertResult(1, "Duplicated project detected\n" + analyzedPlan) {
    +    assertResult(2, "Duplicated project detected\n" + analyzedPlan) {
    --- End diff --
    
    can we test optimized plan here?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    ping @liancheng 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66354281
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala ---
    @@ -1042,7 +1042,7 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
             .queryExecution.analyzed
         }
     
    -    assertResult(1, "Duplicated project detected\n" + analyzedPlan) {
    +    assertResult(2, "Duplicated project detected\n" + analyzedPlan) {
    --- End diff --
    
    I tried. The optimized plan has zero projection. Which one you prefer?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    **[Test build #59931 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/59931/consoleFull)** for PR 13496 at commit [`c809cc6`](https://github.com/apache/spark/commit/c809cc618b3fc30e75345b5d013f58a51c8e91cf).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66729375
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val input = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          Project(inputDataCols ++ inputPartCols, child)
    +        } else {
    +          child
    +        }
    --- End diff --
    
    @gatorsmile Your example confuses me. As the spec you cited, the dynamic partition columns should be last but you put it in the first?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    **[Test build #60206 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60206/consoleFull)** for PR 13496 at commit [`40a7f31`](https://github.com/apache/spark/commit/40a7f315297d13e16aea4c370963867545c3408f).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by liancheng <gi...@git.apache.org>.
Github user liancheng commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    LGTM, merging to master and branch-2.0. Thanks!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66730126
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val input = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          Project(inputDataCols ++ inputPartCols, child)
    +        } else {
    +          child
    +        }
    --- End diff --
    
    @gatorsmile  good catch! The reason we have `insertInto` is to have a SQL INSERT INTO version in `DataFrameWriter`. We should use `saveAsTable` if we need by-name resolution.
    
    I have reverted this PR, @viirya do you mind open a new PR to also remove this logic in `insertInto` to make it consistent with SQL version? thanks!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    **[Test build #60183 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60183/consoleFull)** for PR 13496 at commit [`6888e0a`](https://github.com/apache/spark/commit/6888e0aef0da0946e057daee02078df9f0eac549).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66725456
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val input = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          Project(inputDataCols ++ inputPartCols, child)
    +        } else {
    +          child
    +        }
    --- End diff --
    
    Let me show an example, 
    ```SQL
    INSERT OVERWRITE TABLE $table
    partition (p1='a',p2)
    SELECT 'blarr3' as p2, 'blarr1'
    ```
    
    Without this change, the output is like
    ```
    +------+---+------+
    |    c1| p1|    p2|
    +------+---+------+
    |blarr3|  a|blarr1|
    +------+---+------+
    ```
    After this change, the output becomes
    ```
    +------+---+------+
    |    c1| p1|    p2|
    +------+---+------+
    |blarr1|  a|blarr3|
    +------+---+------+
    ```
    Based on the [Hive specification](https://cwiki.apache.org/confluence/display/Hive/DynamicPartitions), 
    
    >>In INSERT ... SELECT ... queries, the dynamic partition columns must be specified last among the columns in the SELECT statement and in the same order in which they appear in the PARTITION() clause.
    
    Now, the new behavior does not follow the Hive spec. I think we should not do this. 



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66724862
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val input = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          Project(inputDataCols ++ inputPartCols, child)
    +        } else {
    +          child
    +        }
    --- End diff --
    
    After this movement, this will change the output of another code path, i.e., using SQL statements. For example, 
    ```SQL
    insert overwrite table tab1 partition(p1='a', p2) select 'blarr3' as p2, 'blarr1';
    ```
    



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    **[Test build #60206 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60206/consoleFull)** for PR 13496 at commit [`40a7f31`](https://github.com/apache/spark/commit/40a7f315297d13e16aea4c370963867545c3408f).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    **[Test build #59926 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/59926/consoleFull)** for PR 13496 at commit [`83b2e6e`](https://github.com/apache/spark/commit/83b2e6e066611b972e1dddb0b3eb1ae3f8389753).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66729871
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val input = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          Project(inputDataCols ++ inputPartCols, child)
    +        } else {
    +          child
    +        }
    --- End diff --
    
    If we use the name based resolution, we also need to check if the all the input columns have the expected partitioning names; Otherwise, the result will be not predictable. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    LGTM, cc @liancheng 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66729419
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val input = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          Project(inputDataCols ++ inputPartCols, child)
    +        } else {
    +          child
    +        }
    --- End diff --
    
    The names/alias of input columns are not used to determine whether they are the partitioning columns or data columns. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    **[Test build #59926 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/59926/consoleFull)** for PR 13496 at commit [`83b2e6e`](https://github.com/apache/spark/commit/83b2e6e066611b972e1dddb0b3eb1ae3f8389753).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66261309
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,21 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val inputWhenPartsNonEmpty = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          if (child.output == (inputDataCols ++ inputPartCols)) {
    +            child
    +          } else {
    +            Project(inputDataCols ++ inputPartCols, child)
    --- End diff --
    
    Yea, I see. I did this before but two tests in `HiveQuerySuite` will be failed due to this because it tests against the analyzed logical plan...
    
    If we always do project here, we may need to modify `HiveQuerySuite`. Let me do this and then you see if it works for you. Thanks!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    ping @cloud-fan @rxin again this should be simple, can you take a look quickly? Thanks.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    **[Test build #60183 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60183/consoleFull)** for PR 13496 at commit [`6888e0a`](https://github.com/apache/spark/commit/6888e0aef0da0946e057daee02078df9f0eac549).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66198253
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,21 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val inputWhenPartsNonEmpty = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          if (child.output == (inputDataCols ++ inputPartCols)) {
    +            child
    +          } else {
    +            Project(inputDataCols ++ inputPartCols, child)
    --- End diff --
    
    We can always do project, and let optimizer eliminate it for us.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    LGTM except one minor comment, thanks for working on it!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    cc @cloud-fan @yhuai 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/60183/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66729456
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val input = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          Project(inputDataCols ++ inputPartCols, child)
    +        } else {
    +          child
    +        }
    --- End diff --
    
    If the dynamic partitioning columns have multiple columns, the name-based reordering becomes risky. Some partitioning columns might not have names/alias. Right?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66729833
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val input = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          Project(inputDataCols ++ inputPartCols, child)
    +        } else {
    +          child
    +        }
    --- End diff --
    
    Looks like Hive uses ordering not name to take dynamic partition columns. I am not sure if we want to completely follow this Hive behavior. DataFrameWriter's insertInto doesn't follow this. Besides, the rule in Analyzer is not completely follow this too.
    
    @liancheng @rxin @cloud-fan What do you think? Do you think we should change current behavior to follow Hive? 



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/59931/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    **[Test build #59931 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/59931/consoleFull)** for PR 13496 at commit [`c809cc6`](https://github.com/apache/spark/commit/c809cc618b3fc30e75345b5d013f58a51c8e91cf).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    try to ping @yhuai 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyze...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13496#discussion_r66731642
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -452,6 +452,17 @@ class Analyzer(
     
         def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
           case i @ InsertIntoTable(u: UnresolvedRelation, parts, child, _, _) if child.resolved =>
    +        // A partitioned relation's schema can be different from the input logicalPlan, since
    +        // partition columns are all moved after data columns. We Project to adjust the ordering.
    +        val input = if (parts.nonEmpty) {
    +          val (inputPartCols, inputDataCols) = child.output.partition { attr =>
    +            parts.contains(attr.name)
    +          }
    +          Project(inputDataCols ++ inputPartCols, child)
    +        } else {
    +          child
    +        }
    --- End diff --
    
    @cloud-fan ok. I will do it.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/59926/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #13496: [SPARK-15753][SQL] Move Analyzer stuff to Analyzer from ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/13496
  
    also cc @rxin 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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