Skip to content

Commit

Permalink
allowing tests to use functions declared on the schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Nov 21, 2018
1 parent e6c1663 commit 8124d2a
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

Expand All @@ -26,10 +27,11 @@
import org.teiid.adminapi.impl.VDBMetadataParser;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.LRUCache;
import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.MetadataStore;
import org.teiid.metadata.Schema;
import org.teiid.query.function.FunctionTree;
import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.UDFSource;
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.PureZipFileSystem;
import org.teiid.query.metadata.SystemMetadata;
Expand Down Expand Up @@ -69,8 +71,19 @@ public static TransformationMetadata getVDBMetadata(String vdbName, URL vdbURL)
if (r != null) {
vdb = VDBMetadataParser.unmarshell(r.openStream());
}
Collection <FunctionMethod> methods = null;
Collection<FunctionTree> trees = null;
Collection<FunctionTree> trees = new ArrayList<>();
for (Schema schema:imf.store.getSchemas().values()) {
if (!schema.getFunctions().isEmpty()) {
UDFSource source = new UDFSource(schema.getFunctions().values());
trees.add(new FunctionTree(schema.getName(), source, false));
}
if (!schema.getProcedures().isEmpty()) {
FunctionTree ft = FunctionTree.getFunctionProcedures(schema);
if (ft != null) {
trees.add(ft);
}
}
}
SystemFunctionManager sfm = SystemMetadata.getInstance().getSystemFunctionManager();
vdbmetadata = new TransformationMetadata(vdb, new CompositeMetadataStore(Arrays.asList(SystemMetadata.getInstance().getSystemStore(), imf.store)), imf.resources.getEntriesPlusVisibilities(), sfm.getSystemFunctions(), trees);
VDB_CACHE.put(vdbURL, vdbmetadata);
Expand Down

0 comments on commit 8124d2a

Please sign in to comment.