You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/10/24 15:58:30 UTC

[10/12] kylin git commit: Support function with name percentile_approx

Support function with name percentile_approx


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/d79660c0
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/d79660c0
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/d79660c0

Branch: refs/heads/2.2.x
Commit: d79660c0b29a8029a8dd0369f3d05d20e8b875ca
Parents: 0994a57
Author: nichunen <ch...@kyligence.io>
Authored: Tue Oct 24 19:12:00 2017 +0800
Committer: nichunen <ch...@kyligence.io>
Committed: Tue Oct 24 19:12:00 2017 +0800

----------------------------------------------------------------------
 .../percentile/PercentileMeasureType.java       |  8 ++++++--
 .../resources/query/sql_percentile/query01.sql  | 18 ++++++++++++++++++
 .../resources/query/sql_percentile/query02.sql  | 20 ++++++++++++++++++++
 3 files changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/d79660c0/core-metadata/src/main/java/org/apache/kylin/measure/percentile/PercentileMeasureType.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/measure/percentile/PercentileMeasureType.java b/core-metadata/src/main/java/org/apache/kylin/measure/percentile/PercentileMeasureType.java
index 45ebe89..d95a054 100644
--- a/core-metadata/src/main/java/org/apache/kylin/measure/percentile/PercentileMeasureType.java
+++ b/core-metadata/src/main/java/org/apache/kylin/measure/percentile/PercentileMeasureType.java
@@ -36,6 +36,7 @@ public class PercentileMeasureType extends MeasureType<PercentileCounter> {
     // compression ratio saved in DataType.precision
     private final DataType dataType;
     public static final String FUNC_PERCENTILE = "PERCENTILE";
+    public static final String FUNC_PERCENTILE_APPROX = "PERCENTILE_APPROX";
     public static final String DATATYPE_PERCENTILE = "percentile";
 
     public PercentileMeasureType(String funcName, DataType dataType) {
@@ -71,7 +72,8 @@ public class PercentileMeasureType extends MeasureType<PercentileCounter> {
             PercentileCounter current = new PercentileCounter(dataType.getPrecision());
 
             @Override
-            public PercentileCounter valueOf(String[] values, MeasureDesc measureDesc, Map<TblColRef, Dictionary<String>> dictionaryMap) {
+            public PercentileCounter valueOf(String[] values, MeasureDesc measureDesc,
+                    Map<TblColRef, Dictionary<String>> dictionaryMap) {
                 PercentileCounter counter = current;
                 counter.clear();
                 for (String v : values) {
@@ -93,7 +95,9 @@ public class PercentileMeasureType extends MeasureType<PercentileCounter> {
         return true;
     }
 
-    static final Map<String, Class<?>> UDAF_MAP = ImmutableMap.<String, Class<?>> of(PercentileMeasureType.FUNC_PERCENTILE, PercentileAggFunc.class);
+    static final Map<String, Class<?>> UDAF_MAP = ImmutableMap.<String, Class<?>> of(
+            PercentileMeasureType.FUNC_PERCENTILE, PercentileAggFunc.class,
+            PercentileMeasureType.FUNC_PERCENTILE_APPROX, PercentileAggFunc.class);
 
     @Override
     public Map<String, Class<?>> getRewriteCalciteAggrFunctions() {

http://git-wip-us.apache.org/repos/asf/kylin/blob/d79660c0/kylin-it/src/test/resources/query/sql_percentile/query01.sql
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/resources/query/sql_percentile/query01.sql b/kylin-it/src/test/resources/query/sql_percentile/query01.sql
index 4f6d573..35fcb93 100644
--- a/kylin-it/src/test/resources/query/sql_percentile/query01.sql
+++ b/kylin-it/src/test/resources/query/sql_percentile/query01.sql
@@ -1,2 +1,20 @@
+--
+-- 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.
+--
+
 select seller_id, percentile(price, 0.5) from test_kylin_fact
 group by seller_id
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/kylin/blob/d79660c0/kylin-it/src/test/resources/query/sql_percentile/query02.sql
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/resources/query/sql_percentile/query02.sql b/kylin-it/src/test/resources/query/sql_percentile/query02.sql
new file mode 100644
index 0000000..e78b985
--- /dev/null
+++ b/kylin-it/src/test/resources/query/sql_percentile/query02.sql
@@ -0,0 +1,20 @@
+--
+-- 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.
+--
+
+select seller_id, percentile_approx(price, 0.5) from test_kylin_fact
+group by seller_id
\ No newline at end of file