Ian Maxon has uploaded a new change for review.
https://asterix-gerrit.ics.uci.edu/2211
Change subject: [ASTERIXDB-2157] Parsing metadata of UDF with UnorderedList
return type
......................................................................
[ASTERIXDB-2157] Parsing metadata of UDF with UnorderedList return type
Change-Id: Ie9e7795d9c8c212e9610dcb9bb5d26ec9fbbee8b
---
M
asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/functions/ExternalFunctionCompilerUtil.java
A
asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/functions/ExternalFunctionCompilerUtilTest.java
2 files changed, 51 insertions(+), 2 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/11/2211/1
diff --git
a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/functions/ExternalFunctionCompilerUtil.java
b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/functions/ExternalFunctionCompilerUtil.java
index 90c0de3..3d80d0f 100644
---
a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/functions/ExternalFunctionCompilerUtil.java
+++
b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/functions/ExternalFunctionCompilerUtil.java
@@ -163,8 +163,7 @@
@Override
public IAType computeType(ILogicalExpression expression,
IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws
AlgebricksException {
-
- return new AUnorderedListType(type,
type.getTypeName());
+ return new AUnorderedListType(((AUnorderedListType)
type).getItemType(), type.getTypeName());
}
};
diff --git
a/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/functions/ExternalFunctionCompilerUtilTest.java
b/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/functions/ExternalFunctionCompilerUtilTest.java
new file mode 100644
index 0000000..266fab3
--- /dev/null
+++
b/asterixdb/asterix-metadata/src/test/java/org/apache/asterix/metadata/functions/ExternalFunctionCompilerUtilTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+package org.apache.asterix.metadata.functions;
+
+import org.apache.asterix.common.exceptions.MetadataException;
+import org.apache.asterix.common.transactions.JobId;
+import org.apache.asterix.metadata.MetadataTransactionContext;
+import org.apache.asterix.metadata.entities.Function;
+import org.apache.asterix.om.types.AUnorderedListType;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.LinkedList;
+
+public class ExternalFunctionCompilerUtilTest {
+ @Test
+ public void test() throws MetadataException, AlgebricksException {
+ // given
+ MetadataTransactionContext txnCtx = new MetadataTransactionContext(new
JobId(1));
+ Function function = new Function("test", "test", 0, new
LinkedList<String>(), "{{ASTRING}}", "", "JAVA", "SCALAR");
+
+ // when
+ ExternalScalarFunctionInfo info = (ExternalScalarFunctionInfo)
ExternalFunctionCompilerUtil.getExternalFunctionInfo(txnCtx, function);
+ IAType type = info.getResultTypeComputer().computeType(null, null,
null);
+
+ // then
+ IAType expectedType = new AUnorderedListType(BuiltinType.ASTRING,
"AUnorderedList");
+ Assert.assertEquals(expectedType, info.getReturnType());
+ Assert.assertEquals(expectedType, type);
+ }
+}
--
To view, visit https://asterix-gerrit.ics.uci.edu/2211
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie9e7795d9c8c212e9610dcb9bb5d26ec9fbbee8b
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Ian Maxon <[email protected]>
Gerrit-Reviewer: [email protected]