Dmitry Lychagin has submitted this change and it was merged.

Change subject: [ASTERIXDB-2440][COMP] Compiler failure with IN expression
......................................................................


[ASTERIXDB-2440][COMP] Compiler failure with IN expression

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Fixed NullPointerException when IN expression is passed as
  an argument to a function call

Change-Id: I4f9734c37b074ef9b16bc7ae403ae079b86b0e9a
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2890
Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Reviewed-by: Taewoo Kim <wangs...@gmail.com>
---
M 
asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/in_as_or/in_as_or.9.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/in_as_or/in_as_or.9.adm
3 files changed, 29 insertions(+), 9 deletions(-)

Approvals:
  Anon. E. Moose #1000171: 
  Taewoo Kim: Looks good to me, approved
  Jenkins: Verified; No violations found; ; Verified



diff --git 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
index ae9682b..91de474 100644
--- 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
+++ 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
@@ -771,7 +771,7 @@
                     Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = 
langExprToAlgExpression(expr, topOp);
                     AbstractLogicalOperator o1 = (AbstractLogicalOperator) 
eo.second.getValue();
                     args.add(new MutableObject<>(eo.first));
-                    if (o1 != null && !(o1.getOperatorTag() == 
LogicalOperatorTag.ASSIGN && hasOnlyChild(o1, topOp))) {
+                    if (o1 != null) {
                         topOp = eo.second;
                     }
                     break;
@@ -1471,14 +1471,6 @@
         ScalarFunctionCallExpression callExpr = new 
ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(fid));
         callExpr.setSourceLocation(sourceLoc);
         return callExpr;
-    }
-
-    private static boolean hasOnlyChild(ILogicalOperator parent, 
Mutable<ILogicalOperator> childCandidate) {
-        List<Mutable<ILogicalOperator>> inp = parent.getInputs();
-        if (inp == null || inp.size() != 1) {
-            return false;
-        }
-        return inp.get(0) == childCandidate;
     }
 
     protected Pair<ILogicalExpression, Mutable<ILogicalOperator>> 
langExprToAlgExpression(Expression expr,
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/in_as_or/in_as_or.9.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/in_as_or/in_as_or.9.query.sqlpp
new file mode 100644
index 0000000..4b27077
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/in_as_or/in_as_or.9.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * 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 tpch;
+
+select value c.c_custkey
+from Customer c
+where not(c.c_name in ["Customer#000000001", "Customer#000000002", 
"Customer#000000003"])
+order by c.c_custkey
+limit 2
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/in_as_or/in_as_or.9.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/in_as_or/in_as_or.9.adm
new file mode 100644
index 0000000..c79bf28
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/in_as_or/in_as_or.9.adm
@@ -0,0 +1,2 @@
+4
+5
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4f9734c37b074ef9b16bc7ae403ae079b86b0e9a
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Dmitry Lychagin <dmitry.lycha...@couchbase.com>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Dmitry Lychagin <dmitry.lycha...@couchbase.com>
Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Taewoo Kim <wangs...@gmail.com>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-Reviewer: Xikui Wang <xkk...@gmail.com>

Reply via email to