You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by maropu <gi...@git.apache.org> on 2017/05/11 09:14:48 UTC

[GitHub] spark pull request #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

GitHub user maropu opened a pull request:

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

    [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPING SETS

    ## What changes were proposed in this pull request?
    This pr added  `Analyzer` code for supporting aliases in CUBE/ROLLUP/GROUPING SETS (This is follow-up of #17191).
    
    ## How was this patch tested?
    Added tests in `SQLQueryTestSuite`.

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

    $ git pull https://github.com/maropu/spark SPARK-20710

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

    https://github.com/apache/spark/pull/17948.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 #17948
    
----
commit 08cef63604b317cf599e491e65accbe21b4f58b8
Author: Takeshi Yamamuro <ya...@apache.org>
Date:   2017-05-11T08:44:26Z

    Support aliases in CUBE/ROLLUP/GROUPING SETS

----


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    @cloud-fan Could you check this? 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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/76848/
    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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    **[Test build #76849 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76849/testReport)** for PR 17948 at commit [`a809274`](https://github.com/apache/spark/commit/a8092742b99c9d43b04b4a4941345f179996a50f).


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

    https://github.com/apache/spark/pull/17948#discussion_r116152643
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,31 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only if the expression is not
    +    // resolvable by child.
    +    private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean =
    +      !child.output.exists(a => resolver(a.name, attrName))
    --- End diff --
    
    Nit: style
    ```Scala
        private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = {
          !child.output.exists(a => resolver(a.name, attrName))
        }
    ```


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

    https://github.com/apache/spark/pull/17948#discussion_r116161811
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,32 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only if the expression is not
    +    // resolvable by child.
    +    private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = {
    +      !child.output.exists(a => resolver(a.name, attrName))
    +    }
    +
         override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperators {
           case agg @ Aggregate(groups, aggs, child)
               if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    -            groups.exists(_.isInstanceOf[UnresolvedAttribute]) =>
    -        // This is a strict check though, we put this to apply the rule only in alias expressions
    -        def notResolvableByChild(attrName: String): Boolean =
    -          !child.output.exists(a => resolver(a.name, attrName))
    -        agg.copy(groupingExpressions = groups.map {
    -          case u: UnresolvedAttribute if notResolvableByChild(u.name) =>
    +            groups.exists(!_.resolved) =>
    +        agg.copy(groupingExpressions = groups.map { _.transform {
    +            case u: UnresolvedAttribute if notResolvableByChild(u.name, child) =>
    +              aggs.find(ne => resolver(ne.name, u.name)).getOrElse(u)
    +          }
    +        })
    +
    +      case gs @ GroupingSets(selectedGroups, groups, child, aggs)
    +          if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    +            (selectedGroups :+ groups).exists(_.exists(_.isInstanceOf[UnresolvedAttribute])) =>
    --- End diff --
    
    Are we sure that grouping expressions are all pure attributes? If not, this check might fail.


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    thanks, merging to master/2.2


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    **[Test build #76855 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76855/testReport)** for PR 17948 at commit [`ea12790`](https://github.com/apache/spark/commit/ea12790af0ef093c71233f4f3027b884e38a2170).


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

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


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

    https://github.com/apache/spark/pull/17948#discussion_r116151791
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,30 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only in alias expressions
    --- End diff --
    
    ok


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

    https://github.com/apache/spark/pull/17948#discussion_r116159902
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,32 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only if the expression is not
    +    // resolvable by child.
    +    private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = {
    +      !child.output.exists(a => resolver(a.name, attrName))
    +    }
    +
         override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperators {
           case agg @ Aggregate(groups, aggs, child)
               if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    -            groups.exists(_.isInstanceOf[UnresolvedAttribute]) =>
    -        // This is a strict check though, we put this to apply the rule only in alias expressions
    -        def notResolvableByChild(attrName: String): Boolean =
    -          !child.output.exists(a => resolver(a.name, attrName))
    -        agg.copy(groupingExpressions = groups.map {
    -          case u: UnresolvedAttribute if notResolvableByChild(u.name) =>
    +            groups.exists(!_.resolved) =>
    +        agg.copy(groupingExpressions = groups.map { _.transform {
    +            case u: UnresolvedAttribute if notResolvableByChild(u.name, child) =>
    +              aggs.find(ne => resolver(ne.name, u.name)).getOrElse(u)
    +          }
    +        })
    +
    +      case gs @ GroupingSets(selectedGroups, groups, child, aggs)
    +          if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    +            (selectedGroups :+ groups).exists(_.exists(_.isInstanceOf[UnresolvedAttribute])) =>
    --- End diff --
    
    Aha, I see. It looks reasonable. I'll update. 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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    **[Test build #76855 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76855/testReport)** for PR 17948 at commit [`ea12790`](https://github.com/apache/spark/commit/ea12790af0ef093c71233f4f3027b884e38a2170).
     * 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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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/17948#discussion_r116150714
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,30 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only in alias expressions
    --- End diff --
    
    `... only if the expression is not resolvable by child`


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/76849/
    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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    LGTM too.  : )


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    **[Test build #76796 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76796/testReport)** for PR 17948 at commit [`08cef63`](https://github.com/apache/spark/commit/08cef63604b317cf599e491e65accbe21b4f58b8).


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    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 issue #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

    https://github.com/apache/spark/pull/17948#discussion_r116159338
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,32 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only if the expression is not
    +    // resolvable by child.
    +    private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = {
    +      !child.output.exists(a => resolver(a.name, attrName))
    +    }
    +
         override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperators {
           case agg @ Aggregate(groups, aggs, child)
               if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    -            groups.exists(_.isInstanceOf[UnresolvedAttribute]) =>
    -        // This is a strict check though, we put this to apply the rule only in alias expressions
    -        def notResolvableByChild(attrName: String): Boolean =
    -          !child.output.exists(a => resolver(a.name, attrName))
    -        agg.copy(groupingExpressions = groups.map {
    -          case u: UnresolvedAttribute if notResolvableByChild(u.name) =>
    +            groups.exists(!_.resolved) =>
    +        agg.copy(groupingExpressions = groups.map { _.transform {
    +            case u: UnresolvedAttribute if notResolvableByChild(u.name, child) =>
    +              aggs.find(ne => resolver(ne.name, u.name)).getOrElse(u)
    +          }
    +        })
    +
    +      case gs @ GroupingSets(selectedGroups, groups, child, aggs)
    +          if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    +            (selectedGroups :+ groups).exists(_.exists(_.isInstanceOf[UnresolvedAttribute])) =>
    --- End diff --
    
    oh, 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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    **[Test build #76796 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76796/testReport)** for PR 17948 at commit [`08cef63`](https://github.com/apache/spark/commit/08cef63604b317cf599e491e65accbe21b4f58b8).
     * 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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

    https://github.com/apache/spark/pull/17948#discussion_r116153034
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,31 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only if the expression is not
    +    // resolvable by child.
    +    private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean =
    +      !child.output.exists(a => resolver(a.name, attrName))
    --- End diff --
    
    Thanks! Fixed.


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    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 issue #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/76796/
    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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

    https://github.com/apache/spark/pull/17948#discussion_r116155996
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,32 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only if the expression is not
    +    // resolvable by child.
    +    private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = {
    +      !child.output.exists(a => resolver(a.name, attrName))
    +    }
    +
         override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperators {
           case agg @ Aggregate(groups, aggs, child)
               if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    -            groups.exists(_.isInstanceOf[UnresolvedAttribute]) =>
    -        // This is a strict check though, we put this to apply the rule only in alias expressions
    -        def notResolvableByChild(attrName: String): Boolean =
    -          !child.output.exists(a => resolver(a.name, attrName))
    -        agg.copy(groupingExpressions = groups.map {
    -          case u: UnresolvedAttribute if notResolvableByChild(u.name) =>
    +            groups.exists(!_.resolved) =>
    +        agg.copy(groupingExpressions = groups.map { _.transform {
    +            case u: UnresolvedAttribute if notResolvableByChild(u.name, child) =>
    +              aggs.find(ne => resolver(ne.name, u.name)).getOrElse(u)
    +          }
    +        })
    +
    +      case gs @ GroupingSets(selectedGroups, groups, child, aggs)
    +          if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    +            (selectedGroups :+ groups).exists(_.exists(_.isInstanceOf[UnresolvedAttribute])) =>
    +        def mayResolveAttrByAggregateExprs(exprs: Seq[Expression]): Seq[Expression] = exprs.map {
    --- End diff --
    
    I think we should do `exprs.map { _.transform { ...` like above.


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

    https://github.com/apache/spark/pull/17948#discussion_r116155780
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,32 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only if the expression is not
    +    // resolvable by child.
    +    private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = {
    +      !child.output.exists(a => resolver(a.name, attrName))
    +    }
    +
         override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperators {
           case agg @ Aggregate(groups, aggs, child)
               if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    -            groups.exists(_.isInstanceOf[UnresolvedAttribute]) =>
    -        // This is a strict check though, we put this to apply the rule only in alias expressions
    -        def notResolvableByChild(attrName: String): Boolean =
    -          !child.output.exists(a => resolver(a.name, attrName))
    -        agg.copy(groupingExpressions = groups.map {
    -          case u: UnresolvedAttribute if notResolvableByChild(u.name) =>
    +            groups.exists(!_.resolved) =>
    +        agg.copy(groupingExpressions = groups.map { _.transform {
    +            case u: UnresolvedAttribute if notResolvableByChild(u.name, child) =>
    +              aggs.find(ne => resolver(ne.name, u.name)).getOrElse(u)
    +          }
    +        })
    +
    +      case gs @ GroupingSets(selectedGroups, groups, child, aggs)
    +          if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    +            (selectedGroups :+ groups).exists(_.exists(_.isInstanceOf[UnresolvedAttribute])) =>
    --- End diff --
    
    `groups` should cover `selectedGroups`. So we may not need to add `selectedGroups` 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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

    https://github.com/apache/spark/pull/17948#discussion_r116161956
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,32 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only if the expression is not
    +    // resolvable by child.
    +    private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = {
    +      !child.output.exists(a => resolver(a.name, attrName))
    +    }
    +
         override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperators {
           case agg @ Aggregate(groups, aggs, child)
               if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    -            groups.exists(_.isInstanceOf[UnresolvedAttribute]) =>
    -        // This is a strict check though, we put this to apply the rule only in alias expressions
    -        def notResolvableByChild(attrName: String): Boolean =
    -          !child.output.exists(a => resolver(a.name, attrName))
    -        agg.copy(groupingExpressions = groups.map {
    -          case u: UnresolvedAttribute if notResolvableByChild(u.name) =>
    +            groups.exists(!_.resolved) =>
    +        agg.copy(groupingExpressions = groups.map { _.transform {
    +            case u: UnresolvedAttribute if notResolvableByChild(u.name, child) =>
    +              aggs.find(ne => resolver(ne.name, u.name)).getOrElse(u)
    +          }
    +        })
    +
    +      case gs @ GroupingSets(selectedGroups, groups, child, aggs)
    +          if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    +            (selectedGroups :+ groups).exists(_.exists(_.isInstanceOf[UnresolvedAttribute])) =>
    --- End diff --
    
    Oh. nvm. It is of course.


---
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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP...

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

    https://github.com/apache/spark/pull/17948#discussion_r116164177
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1003,18 +1003,32 @@ class Analyzer(
        */
       object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] {
     
    +    // This is a strict check though, we put this to apply the rule only if the expression is not
    +    // resolvable by child.
    +    private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = {
    +      !child.output.exists(a => resolver(a.name, attrName))
    +    }
    +
         override def apply(plan: LogicalPlan): LogicalPlan = plan.resolveOperators {
           case agg @ Aggregate(groups, aggs, child)
               if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    -            groups.exists(_.isInstanceOf[UnresolvedAttribute]) =>
    -        // This is a strict check though, we put this to apply the rule only in alias expressions
    -        def notResolvableByChild(attrName: String): Boolean =
    -          !child.output.exists(a => resolver(a.name, attrName))
    -        agg.copy(groupingExpressions = groups.map {
    -          case u: UnresolvedAttribute if notResolvableByChild(u.name) =>
    +            groups.exists(!_.resolved) =>
    +        agg.copy(groupingExpressions = groups.map { _.transform {
    +            case u: UnresolvedAttribute if notResolvableByChild(u.name, child) =>
    +              aggs.find(ne => resolver(ne.name, u.name)).getOrElse(u)
    +          }
    +        })
    +
    +      case gs @ GroupingSets(selectedGroups, groups, child, aggs)
    +          if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
    +            (selectedGroups :+ groups).exists(_.exists(_.isInstanceOf[UnresolvedAttribute])) =>
    --- End diff --
    
    yea, 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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/76855/
    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 #17948: [SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPI...

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

    https://github.com/apache/spark/pull/17948
  
    **[Test build #76848 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76848/testReport)** for PR 17948 at commit [`0163656`](https://github.com/apache/spark/commit/0163656b8e5325cda7b80e0c0268c24608e9b871).


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