flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-3475) DISTINCT aggregate function support for SQL queries
Date Wed, 18 Jan 2017 05:13:26 GMT

    [ https://issues.apache.org/jira/browse/FLINK-3475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15827438#comment-15827438
] 

ASF GitHub Bot commented on FLINK-3475:
---------------------------------------

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

    https://github.com/apache/flink/pull/3111#discussion_r96568781
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/rules/dataSet/FlinkAggregateExpandDistinctAggregatesRule.java
---
    @@ -0,0 +1,1144 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to you under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.table.plan.rules.dataSet;
    +
    +import org.apache.calcite.plan.Contexts;
    +import org.apache.calcite.plan.RelOptCluster;
    +import org.apache.calcite.plan.RelOptRule;
    +import org.apache.calcite.plan.RelOptRuleCall;
    +import org.apache.calcite.rel.RelNode;
    +import org.apache.calcite.rel.core.Aggregate;
    +import org.apache.calcite.rel.core.AggregateCall;
    +import org.apache.calcite.rel.core.JoinRelType;
    +import org.apache.calcite.rel.core.RelFactories;
    +import org.apache.calcite.rel.logical.LogicalAggregate;
    +import org.apache.calcite.rel.type.RelDataType;
    +import org.apache.calcite.rel.type.RelDataTypeFactory;
    +import org.apache.calcite.rel.type.RelDataTypeField;
    +import org.apache.calcite.rex.RexBuilder;
    +import org.apache.calcite.rex.RexInputRef;
    +import org.apache.calcite.rex.RexNode;
    +import org.apache.calcite.sql.SqlAggFunction;
    +import org.apache.calcite.sql.fun.SqlCountAggFunction;
    +import org.apache.calcite.sql.fun.SqlMinMaxAggFunction;
    +import org.apache.calcite.sql.fun.SqlStdOperatorTable;
    +import org.apache.calcite.sql.fun.SqlSumAggFunction;
    +import org.apache.calcite.sql.fun.SqlSumEmptyIsZeroAggFunction;
    +import org.apache.calcite.sql.type.SqlTypeName;
    +import org.apache.calcite.tools.RelBuilder;
    +import org.apache.calcite.tools.RelBuilderFactory;
    +import org.apache.calcite.util.ImmutableBitSet;
    +import org.apache.calcite.util.ImmutableIntList;
    +import org.apache.calcite.util.Pair;
    +import org.apache.calcite.util.Util;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.Iterables;
    +import com.google.common.collect.Lists;
    +
    +import java.math.BigDecimal;
    +import java.util.ArrayList;
    +import java.util.HashMap;
    +import java.util.LinkedHashSet;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Set;
    +import java.util.SortedSet;
    +import java.util.TreeSet;
    +
    +/**
    + * Planner rule that expands distinct aggregates
    + * (such as {@code COUNT(DISTINCT x)}) from a
    + * {@link org.apache.calcite.rel.logical.LogicalAggregate}.
    + *
    + * <p>How this is done depends upon the arguments to the function. If all
    + * functions have the same argument
    + * (e.g. {@code COUNT(DISTINCT x), SUM(DISTINCT x)} both have the argument
    + * {@code x}) then one extra {@link org.apache.calcite.rel.core.Aggregate} is
    + * sufficient.
    + *
    + * <p>If there are multiple arguments
    + * (e.g. {@code COUNT(DISTINCT x), COUNT(DISTINCT y)})
    + * the rule creates separate {@code Aggregate}s and combines using a
    + * {@link org.apache.calcite.rel.core.Join}.
    + */
    +public final class FlinkAggregateExpandDistinctAggregatesRule extends RelOptRule {
    --- End diff --
    
    classes in org.apache.flink.table.calcite pacage are inspired by calcite and stay in flink,
and FlinkAggregateExpandDistinctAggregatesRule is copied and would be droped. So I don't think
it's a good idea to move this class to it.
    I will move the comment to FlinkAggregateExpandDistinctAggregatesRule, and create a jira
to track to remove it(recommended by @KurtYoung ) 


> DISTINCT aggregate function support for SQL queries
> ---------------------------------------------------
>
>                 Key: FLINK-3475
>                 URL: https://issues.apache.org/jira/browse/FLINK-3475
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table API & SQL
>            Reporter: Chengxiang Li
>            Assignee: Zhenghua Gao
>
> DISTINCT aggregate function may be able to reuse the aggregate function instead of separate
implementation, and let Flink runtime take care of duplicate records.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message