Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ASTERIXDB-2884] Compiler error with nested UDF calls
- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Fix invalid plan produced by ExtractBatchableExternalFunctionCallsRule
- IntroduceDynamicTypeCastForExternalFunctionRule should not introduce
  redundant cast if function argument type is ANY
- Add testcase

Change-Id: I472aa8f828cd548d14d7bda9893984cc4bf25737
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/11445
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
  • Loading branch information
Dmitry Lychagin committed May 13, 2021
1 parent 0e7e4bd commit 86da3f8
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 7 deletions.
Expand Up @@ -190,13 +190,11 @@ private void saveAssignVar(LogicalVariable var, ILogicalExpression expr) {
if (!assignVars.isEmpty()) {
usedVarList.clear();
expr.getUsedVariables(usedVarList);
for (int i = 0, ln = assignVars.size(); i < ln; i++) {
List<LogicalVariable> candidateVarList = assignVars.get(i);
if (OperatorPropertiesUtil.disjoint(candidateVarList, usedVarList)) {
assignVarList = candidateVarList;
assignExprList = assignExprs.get(i);
break;
}
int candidateVarListIdx = assignVars.size() - 1;
List<LogicalVariable> candidateVarList = assignVars.get(candidateVarListIdx);
if (OperatorPropertiesUtil.disjoint(candidateVarList, usedVarList)) {
assignVarList = candidateVarList;
assignExprList = assignExprs.get(candidateVarListIdx);
}
}

Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.ExternalFunctionInfo;
import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
Expand Down Expand Up @@ -82,6 +83,9 @@ private boolean rewriteFunctionArgs(ILogicalOperator op, Mutable<ILogicalExpress
if (reqArgType.getTypeTag() == ATypeTag.OBJECT) {
castFlag = !IntroduceDynamicTypeCastRule.compatible((ARecordType) reqArgType, inputType,
argExpr.getValue().getSourceLocation());
} else if (reqArgType.getTypeTag() == ATypeTag.ANY) {
IAType inputPrimeType = TypeComputeUtils.getActualType(inputType);
castFlag = inputPrimeType.getTypeTag().isDerivedType();
} else {
castFlag = !reqArgType.equals(inputType);
}
Expand Down
@@ -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.
*/

/*
* Testcase for ASTERIXDB-2884
*/

use externallibtest;

sqrt(sqrt(null));

@@ -0,0 +1 @@
null

0 comments on commit 86da3f8

Please sign in to comment.