asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject incubator-asterixdb git commit: ASTERIXDB-1331: fix the type computer for string-length.
Date Fri, 04 Mar 2016 17:57:57 GMT
Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master 640b44807 -> 49fe844a7


ASTERIXDB-1331: fix the type computer for string-length.

Change-Id: Ia21a29049364bd2f99bfd766efdd1518aeffe79f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/689
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <michael.blow@couchbase.com>
Reviewed-by: Ian Maxon <imaxon@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/commit/49fe844a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/tree/49fe844a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/diff/49fe844a

Branch: refs/heads/master
Commit: 49fe844a71217c4228a4fd665fe9f9aa65565b5b
Parents: 640b448
Author: Yingyi Bu <yingyi@couchbase.com>
Authored: Thu Mar 3 22:47:01 2016 -0800
Committer: Yingyi Bu <buyingyi@gmail.com>
Committed: Fri Mar 4 09:53:03 2016 -0800

----------------------------------------------------------------------
 .../query-ASTERIXDB-1331.25.query.sqlpp         | 30 ++++++++++++++
 .../tinysocial-suite.25.query.sqlpp             | 28 +++++++++++++
 .../query-ASTERIXDB-1331.25.adm                 |  1 +
 .../tinysocial-suite/tinysocial-suite.25.adm    |  1 +
 .../query-ASTERIXDB-1331.25.ast                 | 42 ++++++++++++++++++++
 .../tinysocial-suite/tinysocial-suite.25.ast    | 42 ++++++++++++++++++++
 .../UnaryStringInt64OrNullTypeComputer.java     | 13 +++---
 7 files changed, 152 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/49fe844a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.query.sqlpp
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.query.sqlpp
new file mode 100644
index 0000000..8ccf4ef
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+/** This test case is to verify the fix for ASTERIXDB-1331. */
+
+USE TinySocial;
+
+SELECT ELEMENT avg((
+select element "string-length"(message.message)
+FROM FacebookMessages AS message
+WHERE message."in-response-to" >= 1 and
+      message."in-response-to" < 11
+));
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/49fe844a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.query.sqlpp
b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.query.sqlpp
new file mode 100644
index 0000000..7c22f59
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+USE TinySocial;
+
+SELECT ELEMENT avg((
+select element "string-length"(message.message)
+FROM FacebookMessages AS message
+WHERE message."in-response-to" >= 1 and
+      message."in-response-to" < 11
+));
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/49fe844a/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.adm
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.adm
b/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.adm
new file mode 100644
index 0000000..21f0477
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.adm
@@ -0,0 +1 @@
+42.666666666666664d

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/49fe844a/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite/tinysocial-suite.25.adm
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite/tinysocial-suite.25.adm
b/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite/tinysocial-suite.25.adm
new file mode 100644
index 0000000..21f0477
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite/tinysocial-suite.25.adm
@@ -0,0 +1 @@
+42.666666666666664d

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/49fe844a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.ast
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.ast
new file mode 100644
index 0000000..cf21764
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1331.25.ast
@@ -0,0 +1,42 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.avg@1[
+  (
+    SELECT ELEMENT [
+    FunctionCall TinySocial.string-length@1[
+      FieldAccessor [
+        Variable [ Name=message ]
+        Field=message
+      ]
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [FacebookMessages]
+      ]
+      AS
+      Variable [ Name=message ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=message ]
+            Field=in-response-to
+          ]
+          >=
+          LiteralExpr [LONG] [1]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=message ]
+            Field=in-response-to
+          ]
+          <
+          LiteralExpr [LONG] [11]
+        ]
+      ]
+  )
+]
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/49fe844a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.ast
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.ast
b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.ast
new file mode 100644
index 0000000..cf21764
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.25.ast
@@ -0,0 +1,42 @@
+DataverseUse TinySocial
+Query:
+SELECT ELEMENT [
+FunctionCall TinySocial.avg@1[
+  (
+    SELECT ELEMENT [
+    FunctionCall TinySocial.string-length@1[
+      FieldAccessor [
+        Variable [ Name=message ]
+        Field=message
+      ]
+    ]
+    ]
+    FROM [      FunctionCall Metadata.dataset@1[
+        LiteralExpr [STRING] [FacebookMessages]
+      ]
+      AS
+      Variable [ Name=message ]
+    ]
+    Where
+      OperatorExpr [
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=message ]
+            Field=in-response-to
+          ]
+          >=
+          LiteralExpr [LONG] [1]
+        ]
+        and
+        OperatorExpr [
+          FieldAccessor [
+            Variable [ Name=message ]
+            Field=in-response-to
+          ]
+          <
+          LiteralExpr [LONG] [11]
+        ]
+      ]
+  )
+]
+]

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/49fe844a/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64OrNullTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64OrNullTypeComputer.java
b/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64OrNullTypeComputer.java
index b0d8bce..f41a719 100644
--- a/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64OrNullTypeComputer.java
+++ b/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64OrNullTypeComputer.java
@@ -47,8 +47,9 @@ public class UnaryStringInt64OrNullTypeComputer implements IResultTypeComputer
{
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
         AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
-        if (fce.getArguments().isEmpty())
+        if (fce.getArguments().isEmpty()) {
             throw new AlgebricksException("Wrong Argument Number.");
+        }
         ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
         IAType t0;
         try {
@@ -56,10 +57,12 @@ public class UnaryStringInt64OrNullTypeComputer implements IResultTypeComputer
{
         } catch (AlgebricksException e) {
             throw new AlgebricksException(e);
         }
-        if (t0.getTypeTag() != ATypeTag.NULL
-                && t0.getTypeTag() != ATypeTag.STRING
-                && (t0.getTypeTag() == ATypeTag.UNION && !((AUnionType) t0).getUnionList()
-                        .contains(BuiltinType.ASTRING))) {
+        if (t0.getTypeTag() == ATypeTag.ANY) {
+            return BuiltinType.ANY;
+        }
+
+        if (t0.getTypeTag() != ATypeTag.NULL && t0.getTypeTag() != ATypeTag.STRING
&& (t0.getTypeTag() == ATypeTag.UNION
+                && !((AUnionType) t0).getUnionList().contains(BuiltinType.ASTRING)))
{
             throw new NotImplementedException("Expects String Type.");
         }
 


Mime
View raw message