You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by twalthr <gi...@git.apache.org> on 2017/01/06 16:41:46 UTC

[GitHub] flink pull request #2976: [FLINK-5303] [table] Support for SQL GROUPING SETS...

Github user twalthr commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2976#discussion_r94962145
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/rules/dataSet/DataSetAggregateRule.scala ---
    @@ -50,30 +48,48 @@ class DataSetAggregateRule
           throw TableException("DISTINCT aggregates are currently not supported.")
         }
     
    -    // check if we have grouping sets
    -    val groupSets = agg.getGroupSets.size() != 1 || agg.getGroupSets.get(0) != agg.getGroupSet
    -    if (groupSets || agg.indicator) {
    -      throw TableException("GROUPING SETS are currently not supported.")
    -    }
    -
    -    !distinctAggs && !groupSets && !agg.indicator
    +    !distinctAggs
       }
     
       override def convert(rel: RelNode): RelNode = {
         val agg: LogicalAggregate = rel.asInstanceOf[LogicalAggregate]
         val traitSet: RelTraitSet = rel.getTraitSet.replace(DataSetConvention.INSTANCE)
         val convInput: RelNode = RelOptRule.convert(agg.getInput, DataSetConvention.INSTANCE)
     
    -    new DataSetAggregate(
    -      rel.getCluster,
    -      traitSet,
    -      convInput,
    -      agg.getNamedAggCalls,
    -      rel.getRowType,
    -      agg.getInput.getRowType,
    -      agg.getGroupSet.toArray)
    +    if (agg.indicator) {
    +        agg.groupSets.map(set =>
    +          new DataSetAggregate(
    +            rel.getCluster,
    +            traitSet,
    +            convInput,
    +            agg.getNamedAggCalls,
    +            rel.getRowType,
    +            agg.getInput.getRowType,
    +            set.toArray
    +          ).asInstanceOf[RelNode]
    +        ).reduce(
    +          (rel1, rel2) => {
    +            new DataSetUnion(
    +              rel.getCluster,
    +              traitSet,
    +              rel1, rel2,
    --- End diff --
    
    Missing line break.


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