asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Taewoo Kim (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: ASTERIXDB-1155: NULL handling of LimitClause in CloneAndSubs...
Date Wed, 28 Oct 2015 02:54:53 GMT
Taewoo Kim has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/472

Change subject: ASTERIXDB-1155: NULL handling of LimitClause in CloneAndSubstituteVariablesVisitor
fixed. Change-Id: Idd932f2b783454b0216a947bdb4ff35a6b101cd0
......................................................................

ASTERIXDB-1155: NULL handling of LimitClause in CloneAndSubstituteVariablesVisitor fixed.
Change-Id: Idd932f2b783454b0216a947bdb4ff35a6b101cd0
---
A asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.3.query.aql
A asterix-app/src/test/resources/runtimets/results/user-defined-functions/udf31/udf31.1.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
M asterix-aql/src/main/java/org/apache/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
6 files changed, 121 insertions(+), 5 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/72/472/1

diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.1.ddl.aql
b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.1.ddl.aql
new file mode 100644
index 0000000..8678ba0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.1.ddl.aql
@@ -0,0 +1,44 @@
+/*
+ * 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  : Declare a UDF that has a LIMIT in it and try to execute that function.
+ * Expected Res : Success
+ */
+
+drop dataverse emergencyTest if exists;
+create dataverse emergencyTest;
+use dataverse emergencyTest;
+
+create type EmergencyReport as
+{ "id": int,
+  "intensity": int,
+  "message": string
+}
+
+create dataset EmergencyReports(EmergencyReport)
+primary key id;
+
+create function mostIntenseEarthquakeNearLocation()
+{ for $emergency in dataset EmergencyReports
+  order by $emergency.id
+  limit 1
+  return $emergency.message
+}
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.2.update.aql
b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.2.update.aql
new file mode 100644
index 0000000..b656424
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * 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  : Declare a UDF that has a LIMIT in it and try to execute that function.
+ * Expected Res : Success
+ */
+
+use dataverse emergencyTest;
+
+insert into dataset EmergencyReports({"id":1,"intensity":1,message:"emergency1"});
+insert into dataset EmergencyReports({"id":2,"intensity":2,message:"emergency2"});
+insert into dataset EmergencyReports({"id":2,"intensity":3,message:"emergency3"});
+
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.3.query.aql
b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.3.query.aql
new file mode 100644
index 0000000..c8e2b48
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/udf31/udf31.3.query.aql
@@ -0,0 +1,29 @@
+/*
+ * 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  : Declare a UDF that has a LIMIT in it and try to execute that function.
+ * Expected Res : Success
+ */
+
+use dataverse emergencyTest;
+
+for $result in mostIntenseEarthquakeNearLocation()
+return $result;
+
+
diff --git a/asterix-app/src/test/resources/runtimets/results/user-defined-functions/udf31/udf31.1.adm
b/asterix-app/src/test/resources/runtimets/results/user-defined-functions/udf31/udf31.1.adm
new file mode 100644
index 0000000..b6ac4e0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/user-defined-functions/udf31/udf31.1.adm
@@ -0,0 +1,2 @@
+[ "emergency1"
+ ]
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index aef2b54..b6417bc 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -5932,6 +5932,11 @@
             </compilation-unit>
         </test-case>
         <test-case FilePath="user-defined-functions">
+            <compilation-unit name="udf31">
+                <output-dir compare="Text">udf31</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="user-defined-functions">
             <compilation-unit name="f01">
                 <output-dir compare="Text">f01</output-dir>
                 <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
@@ -6159,7 +6164,7 @@
 
     </test-group>
     <test-group name="hdfs">
-    	<test-case FilePath="hdfs">
+      <test-case FilePath="hdfs">
             <compilation-unit name="hdfs_shortcircuit">
                 <output-dir compare="Text">hdfs_shortcircuit</output-dir>
             </compilation-unit>
diff --git a/asterix-aql/src/main/java/org/apache/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
b/asterix-aql/src/main/java/org/apache/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
index b6223cb..c65dbc7 100644
--- a/asterix-aql/src/main/java/org/apache/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
+++ b/asterix-aql/src/main/java/org/apache/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
@@ -87,8 +87,8 @@
 import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.hyracks.algebricks.common.utils.Pair;
 
-public class CloneAndSubstituteVariablesVisitor implements
-        IAqlExpressionVisitor<Pair<IAqlExpression, List<VariableSubstitution>>,
List<VariableSubstitution>> {
+public class CloneAndSubstituteVariablesVisitor
+        implements IAqlExpressionVisitor<Pair<IAqlExpression, List<VariableSubstitution>>,
List<VariableSubstitution>> {
 
     private AqlRewritingContext context;
 
@@ -278,7 +278,13 @@
     public Pair<IAqlExpression, List<VariableSubstitution>> visitLimitClause(LimitClause
lc,
             List<VariableSubstitution> arg) throws AsterixException {
         Pair<IAqlExpression, List<VariableSubstitution>> p1 = lc.getLimitExpr().accept(this,
arg);
-        Pair<IAqlExpression, List<VariableSubstitution>> p2 = lc.getOffset().accept(this,
arg);
+        Pair<IAqlExpression, List<VariableSubstitution>> p2 = null;
+        Expression lcOffsetExpr = lc.getOffset();
+        if (lcOffsetExpr != null) {
+            p2 = lcOffsetExpr.accept(this, arg);
+        } else {
+            p2 = new Pair<IAqlExpression, List<VariableSubstitution>>(null, null);
+        }
         LimitClause c = new LimitClause((Expression) p1.first, (Expression) p2.first);
         return new Pair<IAqlExpression, List<VariableSubstitution>>(c, arg);
     }
@@ -628,7 +634,6 @@
         // TODO Auto-generated method stub
         return null;
     }
-    
 
     @Override
     public Pair<IAqlExpression, List<VariableSubstitution>> visitCreateFeedPolicyStatement(

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/472
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd932f2b783454b0216a947bdb4ff35a6b101cd0
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Taewoo Kim <wangsaeu@gmail.com>

Mime
View raw message