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

[GitHub] spark pull request: [SPARK-13637][SQL] use more information to sim...

GitHub user cloud-fan opened a pull request:

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

    [SPARK-13637][SQL] use more information to simplify the code in Expand builder

    ## What changes were proposed in this pull request?
    
    The code in `Expand.apply` can be simplified by existing information:
    
    * the `groupByExprs` parameter are all `Attribute`s
    * the `child` parameter is a `Project` that append aliased group by expressions to its child's output
    
    
    ## How was this patch tested?
    
    by existing tests.


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

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

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

    https://github.com/apache/spark/pull/11485.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 #11485
    
----
commit 9db97ec3f641cba9b069821b456ed8a0dfbd905c
Author: Wenchen Fan <we...@databricks.com>
Date:   2016-03-03T05:33:56Z

    use more information to simplify the code in Expand builder

----


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191680718
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52386/
    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: [SPARK-13637][SQL] use more information to sim...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on the pull request:

    https://github.com/apache/spark/pull/11485#issuecomment-193811516
  
    LGTM


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191726855
  
    **[Test build #52394 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52394/consoleFull)** for PR 11485 at commit [`9db97ec`](https://github.com/apache/spark/commit/9db97ec3f641cba9b069821b456ed8a0dfbd905c).


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-193791254
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52666/
    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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-193790898
  
    **[Test build #52666 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52666/consoleFull)** for PR 11485 at commit [`4f31c5c`](https://github.com/apache/spark/commit/4f31c5c8e1461a63a6e4ce9f74712b746ad098f4).
     * 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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-192092226
  
    **[Test build #52435 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52435/consoleFull)** for PR 11485 at commit [`4f31c5c`](https://github.com/apache/spark/commit/4f31c5c8e1461a63a6e4ce9f74712b746ad098f4).
     * 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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191624450
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52370/
    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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191648049
  
    **[Test build #52386 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52386/consoleFull)** for PR 11485 at commit [`9db97ec`](https://github.com/apache/spark/commit/9db97ec3f641cba9b069821b456ed8a0dfbd905c).


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191767739
  
    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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191646672
  
    retest this please


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191767741
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52394/
    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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-192092752
  
    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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191623918
  
    **[Test build #52370 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52370/consoleFull)** for PR 11485 at commit [`9db97ec`](https://github.com/apache/spark/commit/9db97ec3f641cba9b069821b456ed8a0dfbd905c).
     * 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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-193757000
  
    retest this please


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#discussion_r54843328
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicOperators.scala ---
    @@ -473,41 +473,44 @@ private[sql] object Expand {
        * multiple output rows for a input row.
        *
        * @param bitmasks The bitmask set represents the grouping sets
    -   * @param groupByExprs The grouping by expressions
    +   * @param groupByAttrs The attributes of aliased group by expressions
        * @param gid Attribute of the grouping id
    -   * @param child Child operator
    +   * @param project The child project operator
        */
       def apply(
         bitmasks: Seq[Int],
    -    groupByExprs: Seq[Expression],
    +    groupByAttrs: Seq[Attribute],
         gid: Attribute,
    -    child: LogicalPlan): Expand = {
    +    project: Project): Expand = {
    +
    +    val originalOutput = project.child.output
    +    assert(project.output.length == (originalOutput ++ groupByAttrs).length)
    +    assert(project.output.zip(originalOutput ++ groupByAttrs).forall {
    +      case (attr1, attr2) => attr1 semanticEquals attr2
    +    })
    +
         // Create an array of Projections for the child projection, and replace the projections'
         // expressions which equal GroupBy expressions with Literal(null), if those expressions
         // are not set for this grouping set (according to the bit mask).
         val projections = bitmasks.map { bitmask =>
           // get the non selected grouping attributes according to the bit mask
    -      val nonSelectedGroupExprSet = buildNonSelectExprSet(bitmask, groupByExprs)
    +      val nonSelectedGroupAttrSet = buildNonSelectAttrSet(bitmask, groupByAttrs)
     
    -      (child.output :+ gid).map(expr => expr transformDown {
    -        // TODO this causes a problem when a column is used both for grouping and aggregation.
    --- End diff --
    
    I believe this is for cube and rollup. Now, we covered all the cases.


---
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: [SPARK-13637][SQL] use more information to sim...

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

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


---
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: [SPARK-13637][SQL] use more information to sim...

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/11485#discussion_r54838393
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicOperators.scala ---
    @@ -473,41 +473,44 @@ private[sql] object Expand {
        * multiple output rows for a input row.
        *
        * @param bitmasks The bitmask set represents the grouping sets
    -   * @param groupByExprs The grouping by expressions
    +   * @param groupByAttrs The attributes of aliased group by expressions
        * @param gid Attribute of the grouping id
    -   * @param child Child operator
    +   * @param project The child project operator
        */
       def apply(
         bitmasks: Seq[Int],
    -    groupByExprs: Seq[Expression],
    +    groupByAttrs: Seq[Attribute],
         gid: Attribute,
    -    child: LogicalPlan): Expand = {
    +    project: Project): Expand = {
    +
    +    val originalOutput = project.child.output
    +    assert(project.output.length == (originalOutput ++ groupByAttrs).length)
    +    assert(project.output.zip(originalOutput ++ groupByAttrs).forall {
    +      case (attr1, attr2) => attr1 semanticEquals attr2
    +    })
    +
         // Create an array of Projections for the child projection, and replace the projections'
         // expressions which equal GroupBy expressions with Literal(null), if those expressions
         // are not set for this grouping set (according to the bit mask).
         val projections = bitmasks.map { bitmask =>
           // get the non selected grouping attributes according to the bit mask
    -      val nonSelectedGroupExprSet = buildNonSelectExprSet(bitmask, groupByExprs)
    +      val nonSelectedGroupAttrSet = buildNonSelectAttrSet(bitmask, groupByAttrs)
     
    -      (child.output :+ gid).map(expr => expr transformDown {
    -        // TODO this causes a problem when a column is used both for grouping and aggregation.
    --- End diff --
    
    Is this comment still valid?


---
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: [SPARK-13637][SQL] use more information to sim...

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/11485#discussion_r54888839
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicOperators.scala ---
    @@ -473,41 +473,44 @@ private[sql] object Expand {
        * multiple output rows for a input row.
        *
        * @param bitmasks The bitmask set represents the grouping sets
    -   * @param groupByExprs The grouping by expressions
    +   * @param groupByAttrs The attributes of aliased group by expressions
        * @param gid Attribute of the grouping id
    -   * @param child Child operator
    +   * @param project The child project operator
        */
       def apply(
         bitmasks: Seq[Int],
    -    groupByExprs: Seq[Expression],
    +    groupByAttrs: Seq[Attribute],
         gid: Attribute,
    -    child: LogicalPlan): Expand = {
    +    project: Project): Expand = {
    +
    +    val originalOutput = project.child.output
    +    assert(project.output.length == (originalOutput ++ groupByAttrs).length)
    +    assert(project.output.zip(originalOutput ++ groupByAttrs).forall {
    +      case (attr1, attr2) => attr1 semanticEquals attr2
    +    })
    +
         // Create an array of Projections for the child projection, and replace the projections'
         // expressions which equal GroupBy expressions with Literal(null), if those expressions
         // are not set for this grouping set (according to the bit mask).
         val projections = bitmasks.map { bitmask =>
           // get the non selected grouping attributes according to the bit mask
    -      val nonSelectedGroupExprSet = buildNonSelectExprSet(bitmask, groupByExprs)
    +      val nonSelectedGroupAttrSet = buildNonSelectAttrSet(bitmask, groupByAttrs)
     
    -      (child.output :+ gid).map(expr => expr transformDown {
    -        // TODO this causes a problem when a column is used both for grouping and aggregation.
    --- End diff --
    
    ah, so it's time to remove this TODO :)


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-192092754
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52435/
    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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-192067080
  
    **[Test build #52435 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52435/consoleFull)** for PR 11485 at commit [`4f31c5c`](https://github.com/apache/spark/commit/4f31c5c8e1461a63a6e4ce9f74712b746ad098f4).


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#discussion_r54842640
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicOperators.scala ---
    @@ -473,41 +473,44 @@ private[sql] object Expand {
        * multiple output rows for a input row.
        *
        * @param bitmasks The bitmask set represents the grouping sets
    -   * @param groupByExprs The grouping by expressions
    +   * @param groupByAttrs The attributes of aliased group by expressions
        * @param gid Attribute of the grouping id
    -   * @param child Child operator
    +   * @param project The child project operator
        */
       def apply(
         bitmasks: Seq[Int],
    -    groupByExprs: Seq[Expression],
    +    groupByAttrs: Seq[Attribute],
         gid: Attribute,
    -    child: LogicalPlan): Expand = {
    +    project: Project): Expand = {
    +
    +    val originalOutput = project.child.output
    +    assert(project.output.length == (originalOutput ++ groupByAttrs).length)
    +    assert(project.output.zip(originalOutput ++ groupByAttrs).forall {
    +      case (attr1, attr2) => attr1 semanticEquals attr2
    +    })
    +
         // Create an array of Projections for the child projection, and replace the projections'
         // expressions which equal GroupBy expressions with Literal(null), if those expressions
         // are not set for this grouping set (according to the bit mask).
         val projections = bitmasks.map { bitmask =>
           // get the non selected grouping attributes according to the bit mask
    -      val nonSelectedGroupExprSet = buildNonSelectExprSet(bitmask, groupByExprs)
    +      val nonSelectedGroupAttrSet = buildNonSelectAttrSet(bitmask, groupByAttrs)
     
    -      (child.output :+ gid).map(expr => expr transformDown {
    -        // TODO this causes a problem when a column is used both for grouping and aggregation.
    --- End diff --
    
    It isn't anymore. We had some trouble with such columns when I placed the comment.


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-193758948
  
    **[Test build #52666 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52666/consoleFull)** for PR 11485 at commit [`4f31c5c`](https://github.com/apache/spark/commit/4f31c5c8e1461a63a6e4ce9f74712b746ad098f4).


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191767426
  
    **[Test build #52394 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52394/consoleFull)** for PR 11485 at commit [`9db97ec`](https://github.com/apache/spark/commit/9db97ec3f641cba9b069821b456ed8a0dfbd905c).
     * 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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191593106
  
    **[Test build #52370 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52370/consoleFull)** for PR 11485 at commit [`9db97ec`](https://github.com/apache/spark/commit/9db97ec3f641cba9b069821b456ed8a0dfbd905c).


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191620404
  
    @hvanhovell you might as well review 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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191726573
  
    retest this please


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191624448
  
    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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191680716
  
    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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-193791247
  
    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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-193826541
  
    Thanks for the review! Merging to master


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#discussion_r54843612
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicOperators.scala ---
    @@ -473,41 +473,44 @@ private[sql] object Expand {
        * multiple output rows for a input row.
        *
        * @param bitmasks The bitmask set represents the grouping sets
    -   * @param groupByExprs The grouping by expressions
    +   * @param groupByAttrs The attributes of aliased group by expressions
        * @param gid Attribute of the grouping id
    -   * @param child Child operator
    +   * @param project The child project operator
        */
       def apply(
         bitmasks: Seq[Int],
    -    groupByExprs: Seq[Expression],
    +    groupByAttrs: Seq[Attribute],
         gid: Attribute,
    -    child: LogicalPlan): Expand = {
    +    project: Project): Expand = {
    +
    +    val originalOutput = project.child.output
    +    assert(project.output.length == (originalOutput ++ groupByAttrs).length)
    +    assert(project.output.zip(originalOutput ++ groupByAttrs).forall {
    +      case (attr1, attr2) => attr1 semanticEquals attr2
    +    })
    +
         // Create an array of Projections for the child projection, and replace the projections'
         // expressions which equal GroupBy expressions with Literal(null), if those expressions
         // are not set for this grouping set (according to the bit mask).
         val projections = bitmasks.map { bitmask =>
           // get the non selected grouping attributes according to the bit mask
    -      val nonSelectedGroupExprSet = buildNonSelectExprSet(bitmask, groupByExprs)
    +      val nonSelectedGroupAttrSet = buildNonSelectAttrSet(bitmask, groupByAttrs)
     
    -      (child.output :+ gid).map(expr => expr transformDown {
    -        // TODO this causes a problem when a column is used both for grouping and aggregation.
    --- End diff --
    
    @gatorsmile **is** or **was**? If it is what is currently still broken?


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#issuecomment-191680443
  
    **[Test build #52386 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52386/consoleFull)** for PR 11485 at commit [`9db97ec`](https://github.com/apache/spark/commit/9db97ec3f641cba9b069821b456ed8a0dfbd905c).
     * 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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#discussion_r54887348
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicOperators.scala ---
    @@ -473,41 +473,44 @@ private[sql] object Expand {
        * multiple output rows for a input row.
        *
        * @param bitmasks The bitmask set represents the grouping sets
    -   * @param groupByExprs The grouping by expressions
    +   * @param groupByAttrs The attributes of aliased group by expressions
        * @param gid Attribute of the grouping id
    -   * @param child Child operator
    +   * @param project The child project operator
        */
       def apply(
         bitmasks: Seq[Int],
    -    groupByExprs: Seq[Expression],
    +    groupByAttrs: Seq[Attribute],
         gid: Attribute,
    -    child: LogicalPlan): Expand = {
    +    project: Project): Expand = {
    +
    +    val originalOutput = project.child.output
    +    assert(project.output.length == (originalOutput ++ groupByAttrs).length)
    +    assert(project.output.zip(originalOutput ++ groupByAttrs).forall {
    +      case (attr1, attr2) => attr1 semanticEquals attr2
    +    })
    +
         // Create an array of Projections for the child projection, and replace the projections'
         // expressions which equal GroupBy expressions with Literal(null), if those expressions
         // are not set for this grouping set (according to the bit mask).
         val projections = bitmasks.map { bitmask =>
           // get the non selected grouping attributes according to the bit mask
    -      val nonSelectedGroupExprSet = buildNonSelectExprSet(bitmask, groupByExprs)
    +      val nonSelectedGroupAttrSet = buildNonSelectAttrSet(bitmask, groupByAttrs)
     
    -      (child.output :+ gid).map(expr => expr transformDown {
    -        // TODO this causes a problem when a column is used both for grouping and aggregation.
    --- End diff --
    
    Just did a code history search. Sorry, this line was added by you. You know, cube and rollup also use Expand. Previously, cube and rollup had a couple of issues in grouping and aggregation. Now, all the issues have been fixed. 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 pull request: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#discussion_r54940911
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicOperators.scala ---
    @@ -473,41 +473,44 @@ private[sql] object Expand {
        * multiple output rows for a input row.
        *
        * @param bitmasks The bitmask set represents the grouping sets
    -   * @param groupByExprs The grouping by expressions
    +   * @param groupByAttrs The attributes of aliased group by expressions
        * @param gid Attribute of the grouping id
    -   * @param child Child operator
    +   * @param project The child project operator
        */
       def apply(
         bitmasks: Seq[Int],
    -    groupByExprs: Seq[Expression],
    +    groupByAttrs: Seq[Attribute],
         gid: Attribute,
    -    child: LogicalPlan): Expand = {
    --- End diff --
    
    Why not move the creation of the Project from the analyzer into this method? Then we can just take any logical plan as an argument.


---
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: [SPARK-13637][SQL] use more information to sim...

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

    https://github.com/apache/spark/pull/11485#discussion_r54940996
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicOperators.scala ---
    @@ -473,41 +473,44 @@ private[sql] object Expand {
        * multiple output rows for a input row.
        *
        * @param bitmasks The bitmask set represents the grouping sets
    -   * @param groupByExprs The grouping by expressions
    +   * @param groupByAttrs The attributes of aliased group by expressions
        * @param gid Attribute of the grouping id
    -   * @param child Child operator
    +   * @param project The child project operator
        */
       def apply(
         bitmasks: Seq[Int],
    -    groupByExprs: Seq[Expression],
    +    groupByAttrs: Seq[Attribute],
         gid: Attribute,
    -    child: LogicalPlan): Expand = {
    +    project: Project): Expand = {
    +
    +    val originalOutput = project.child.output
    +    assert(project.output.length == (originalOutput ++ groupByAttrs).length)
    +    assert(project.output.zip(originalOutput ++ groupByAttrs).forall {
    +      case (attr1, attr2) => attr1 semanticEquals attr2
    +    })
    +
         // Create an array of Projections for the child projection, and replace the projections'
         // expressions which equal GroupBy expressions with Literal(null), if those expressions
         // are not set for this grouping set (according to the bit mask).
         val projections = bitmasks.map { bitmask =>
           // get the non selected grouping attributes according to the bit mask
    -      val nonSelectedGroupExprSet = buildNonSelectExprSet(bitmask, groupByExprs)
    +      val nonSelectedGroupAttrSet = buildNonSelectAttrSet(bitmask, groupByAttrs)
     
    -      (child.output :+ gid).map(expr => expr transformDown {
    -        // TODO this causes a problem when a column is used both for grouping and aggregation.
    -        case x: Expression if nonSelectedGroupExprSet.exists(_.semanticEquals(x)) =>
    +      originalOutput ++ groupByAttrs.map { attr =>
    +        if (nonSelectedGroupAttrSet.contains(attr)) {
               // if the input attribute in the Invalid Grouping Expression set of for this group
               // replace it with constant null
    -          Literal.create(null, expr.dataType)
    -        case x if x == gid =>
    -          // replace the groupingId with concrete value (the bit mask)
    -          Literal.create(bitmask, IntegerType)
    -      })
    -    }
    -    val output = child.output.map { attr =>
    -      if (groupByExprs.exists(_.semanticEquals(attr))) {
    -        attr.withNullability(true)
    -      } else {
    -        attr
    +          Literal.create(null, attr.dataType)
    +        } else {
    +          attr
    +        }
    +      } :+ {
    --- End diff --
    
    Nit: Funny brackets... Any reason for this besides this comment?


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