You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by dl...@apache.org on 2019/06/18 18:03:45 UTC

[asterixdb] branch master updated: [NO ISSUE][FUN] Allow frame in RATIO_TO_REPORT()

This is an automated email from the ASF dual-hosted git repository.

dlych pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 582bfa2  [NO ISSUE][FUN] Allow frame in RATIO_TO_REPORT()
582bfa2 is described below

commit 582bfa287f859d717cfcb79524bb5042b0f1c433
Author: Dmitry Lychagin <dm...@couchbase.com>
AuthorDate: Mon Jun 17 16:50:48 2019 -0700

    [NO ISSUE][FUN] Allow frame in RATIO_TO_REPORT()
    
    - user model changes: yes
    - storage format changes: no
    - interface changes: no
    
    Details:
    - Support frame specification in RATIO_TO_REPORT()
      window function call
    
    Change-Id: Ibc3686bebaf791aa84ef34d8fd143e53edc7856a
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/3449
    Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Dmitry Lychagin <dm...@couchbase.com>
    Reviewed-by: Ali Alsuliman <al...@gmail.com>
---
 .../SqlppExpressionToPlanTranslator.java           |  5 ----
 .../ratio_to_report_01.8.query.sqlpp               | 27 ++++++++++++++++++++++
 .../ratio_to_report_01/ratio_to_report_01.8.adm    |  8 +++++++
 .../asterix/om/functions/BuiltinFunctions.java     |  2 +-
 4 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java
index 1c5750c..988723f 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java
@@ -1228,11 +1228,6 @@ public class SqlppExpressionToPlanTranslator extends LangExpressionToPlanTransla
                         createOperatorExpr(fargs.get(1), OperatorType.MINUS, new IntegerLiteral(1), sourceLoc);
             } else if (BuiltinFunctions.RATIO_TO_REPORT_IMPL.equals(fi)) {
                 // ratio_to_report(x) over (...) --> x / sum(x) over (...)
-                winFrameMode = WindowExpression.FrameMode.RANGE;
-                winFrameStartKind = WindowExpression.FrameBoundaryKind.UNBOUNDED_PRECEDING;
-                winFrameEndKind = WindowExpression.FrameBoundaryKind.CURRENT_ROW;
-                winFrameExclusionKind = WindowExpression.FrameExclusionKind.NO_OTHERS;
-
                 nestedAggFunc = BuiltinFunctions.SCALAR_SQL_SUM;
                 postWinResultFunc = BuiltinFunctions.NUMERIC_DIVIDE;
                 postWinExpr = fargs.get(1);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/window/ratio_to_report_01/ratio_to_report_01.8.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/window/ratio_to_report_01/ratio_to_report_01.8.query.sqlpp
new file mode 100644
index 0000000..9408641
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/window/ratio_to_report_01/ratio_to_report_01.8.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+/*
+ * Description  : Test RATIO_TO_REPORT() with frame specification
+ * Expected Res : SUCCESS
+ */
+
+FROM range(1, 2) x, range(1, 4) y
+SELECT x, y,
+  round_half_to_even(ratio_to_report(y) over (partition by x order by y rows between 1 preceding and 1 following), 2) rr
+ORDER BY x, y
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/window/ratio_to_report_01/ratio_to_report_01.8.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/window/ratio_to_report_01/ratio_to_report_01.8.adm
new file mode 100644
index 0000000..5ff1afc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/window/ratio_to_report_01/ratio_to_report_01.8.adm
@@ -0,0 +1,8 @@
+{ "x": 1, "y": 1, "rr": 0.33 }
+{ "x": 1, "y": 2, "rr": 0.33 }
+{ "x": 1, "y": 3, "rr": 0.33 }
+{ "x": 1, "y": 4, "rr": 0.57 }
+{ "x": 2, "y": 1, "rr": 0.33 }
+{ "x": 2, "y": 2, "rr": 0.33 }
+{ "x": 2, "y": 3, "rr": 0.33 }
+{ "x": 2, "y": 4, "rr": 0.57 }
\ No newline at end of file
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
index 7afda20..5e2257a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
@@ -2967,7 +2967,7 @@ public class BuiltinFunctions {
         addWindowFunction(NTILE, NTILE_IMPL, NO_FRAME_CLAUSE, MATERIALIZE_PARTITION);
         addWindowFunction(PERCENT_RANK, PERCENT_RANK_IMPL, NO_FRAME_CLAUSE, INJECT_ORDER_ARGS, MATERIALIZE_PARTITION);
         addWindowFunction(RANK, RANK_IMPL, NO_FRAME_CLAUSE, INJECT_ORDER_ARGS);
-        addWindowFunction(RATIO_TO_REPORT, RATIO_TO_REPORT_IMPL, NO_FRAME_CLAUSE, HAS_LIST_ARG);
+        addWindowFunction(RATIO_TO_REPORT, RATIO_TO_REPORT_IMPL, HAS_LIST_ARG);
         addWindowFunction(ROW_NUMBER, ROW_NUMBER_IMPL, NO_FRAME_CLAUSE);
         addWindowFunction(WIN_PARTITION_LENGTH, WIN_PARTITION_LENGTH_IMPL, NO_FRAME_CLAUSE, MATERIALIZE_PARTITION);
     }