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/03/14 15:39:40 UTC

[asterixdb] branch master updated: [ASTERIXDB-2530][COMP] Error computing type for numeric add

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 3b545d7  [ASTERIXDB-2530][COMP] Error computing type for numeric add
3b545d7 is described below

commit 3b545d7c1977ee3189e461f2af243b0fef342e33
Author: Dmitry Lychagin <dm...@couchbase.com>
AuthorDate: Wed Mar 13 11:34:58 2019 -0700

    [ASTERIXDB-2530][COMP] Error computing type for numeric add
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    - Fixed type computation for numeric add when first argument
      is of type ANY and second argument is of a temporal type
    
    Change-Id: I4beac66a6a71179bb3214d27a820f3306533b03c
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/3271
    Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Ali Alsuliman <al...@gmail.com>
---
 .../query-ASTERIXDB-2530.1.query.sqlpp             | 32 ++++++++++++++++++++++
 .../query-ASTERIXDB-2530.1.adm                     |  2 ++
 .../test/resources/runtimets/testsuite_sqlpp.xml   |  5 ++++
 .../impl/NumericAddSubMulDivTypeComputer.java      |  8 +++++-
 4 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-ASTERIXDB-2530/query-ASTERIXDB-2530.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-ASTERIXDB-2530/query-ASTERIXDB-2530.1.query.sqlpp
new file mode 100644
index 0000000..d4e533b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/numeric/query-ASTERIXDB-2530/query-ASTERIXDB-2530.1.query.sqlpp
@@ -0,0 +1,32 @@
+/*
+ * 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 type computation for numeric add when first
+  *                : argument is of type ANY and second argument is a duration
+  * Success        : Yes
+  */
+
+from range(1, 2) x
+let y =
+  case when x > 1
+  then date("2011-11-11")
+  else datetime("2011-11-11T11:11:11Z")
+  end
+select y + year_month_duration("P" || tostring(x) || "Y") res
+order by x
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/query-ASTERIXDB-2530/query-ASTERIXDB-2530.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/query-ASTERIXDB-2530/query-ASTERIXDB-2530.1.adm
new file mode 100644
index 0000000..6dd4bdb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/numeric/query-ASTERIXDB-2530/query-ASTERIXDB-2530.1.adm
@@ -0,0 +1,2 @@
+{ "res": datetime("2012-11-11T11:11:11.000Z") }
+{ "res": date("2013-11-11") }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 42e3024..0b221bf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -6852,6 +6852,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="numeric">
+      <compilation-unit name="query-ASTERIXDB-2530">
+        <output-dir compare="Text">query-ASTERIXDB-2530</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="numeric">
       <compilation-unit name="radians">
         <output-dir compare="Text">radians</output-dir>
       </compilation-unit>
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
index 47ad411..41a60c6 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
@@ -195,8 +195,14 @@ public class NumericAddSubMulDivTypeComputer extends AbstractResultTypeComputer
                     case INTEGER:
                     case BIGINT:
                     case FLOAT:
-                    case ANY:
                     case DOUBLE:
+                    case DATE:
+                    case TIME:
+                    case DATETIME:
+                    case DURATION:
+                    case YEARMONTHDURATION:
+                    case DAYTIMEDURATION:
+                    case ANY:
                         type = BuiltinType.ANY;
                         break;
                     default: