Skip to content

Commit 62feff1

Browse files
tpawlowskimblow
authored andcommitted
[ASTERIXDB-2157] Parsing metadata of UDF with UnorderedList return type
changes from #6 Change-Id: Ie9e7795d9c8c212e9610dcb9bb5d26ec9fbbee8b Reviewed-on: https://asterix-gerrit.ics.uci.edu/2211 Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Reviewed-by: Till Westmann <tillw@apache.org>
1 parent f125348 commit 62feff1

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/functions/ExternalFunctionCompilerUtil.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironmen
163163
@Override
164164
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
165165
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
166-
167-
return new AUnorderedListType(type, type.getTypeName());
166+
return new AUnorderedListType(((AUnorderedListType) type).getItemType(), type.getTypeName());
168167
}
169168

170169
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.asterix.metadata.functions;
20+
21+
import java.util.LinkedList;
22+
23+
import org.apache.asterix.common.transactions.TxnId;
24+
import org.apache.asterix.metadata.MetadataTransactionContext;
25+
import org.apache.asterix.metadata.entities.Function;
26+
import org.apache.asterix.om.types.AUnorderedListType;
27+
import org.apache.asterix.om.types.BuiltinType;
28+
import org.apache.asterix.om.types.IAType;
29+
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
30+
import org.junit.Assert;
31+
import org.junit.Test;
32+
33+
public class ExternalFunctionCompilerUtilTest {
34+
@Test
35+
public void test() throws AlgebricksException {
36+
// given
37+
MetadataTransactionContext txnCtx = new MetadataTransactionContext(new TxnId(1));
38+
Function function =
39+
new Function("test", "test", 0, new LinkedList<>(), "{{ASTRING}}", "", "JAVA", "SCALAR", null);
40+
41+
// when
42+
ExternalScalarFunctionInfo info =
43+
(ExternalScalarFunctionInfo) ExternalFunctionCompilerUtil.getExternalFunctionInfo(txnCtx, function);
44+
IAType type = info.getResultTypeComputer().computeType(null, null, null);
45+
46+
// then
47+
IAType expectedType = new AUnorderedListType(BuiltinType.ASTRING, "AUnorderedList");
48+
Assert.assertEquals(expectedType, info.getReturnType());
49+
Assert.assertEquals(expectedType, type);
50+
}
51+
}

0 commit comments

Comments
 (0)