private UDFMetaData getUDF() { UDFMetaData mergedUDF = new UDFMetaData(); if (this.udf != null) { mergedUDF.addFunctions(this.udf); } for (Schema schema : store.getSchemas().values()) { Collection<FunctionMethod> funcs = schema.getFunctions().values(); mergedUDF.addFunctions(schema.getName(), funcs); } if (this.cmr != null) { // system scoped common source functions for (ConnectorManager cm : this.cmr.getConnectorManagers().values()) { List<FunctionMethod> funcs = cm.getPushDownFunctions(); mergedUDF.addFunctions(CoreConstants.SYSTEM_MODEL, funcs); } } if (this.children != null) { // udf model functions - also scoped to the model for (CompositeVDB child : this.children.values()) { UDFMetaData funcs = child.getUDF(); if (funcs != null) { mergedUDF.addFunctions(funcs); } } } return mergedUDF; }
private static TransformationMetadata buildTransformationMetaData( VDBMetaData vdb, LinkedHashMap<String, VDBResources.Resource> visibilityMap, MetadataStore store, UDFMetaData udf, FunctionTree systemFunctions, MetadataStore[] additionalStores) { Collection<FunctionTree> udfs = new ArrayList<FunctionTree>(); if (udf != null) { for (Map.Entry<String, UDFSource> entry : udf.getFunctions().entrySet()) { udfs.add(new FunctionTree(entry.getKey(), entry.getValue(), true)); } } CompositeMetadataStore compositeStore = new CompositeMetadataStore(store); for (MetadataStore s : additionalStores) { compositeStore.merge(s); for (Schema schema : s.getSchemas().values()) { if (!schema.getFunctions().isEmpty()) { UDFSource source = new UDFSource(schema.getFunctions().values()); if (udf != null) { source.setClassLoader(udf.getClassLoader()); } udfs.add(new FunctionTree(schema.getName(), source, true)); } if (!schema.getProcedures().isEmpty()) { FunctionTree ft = FunctionTree.getFunctionProcedures(schema); if (ft != null) { udfs.add(ft); } } } } TransformationMetadata metadata = new TransformationMetadata(vdb, compositeStore, visibilityMap, systemFunctions, udfs); metadata.setUseOutputNames(false); metadata.setWidenComparisonToString(WIDEN_COMPARISON_TO_STRING); return metadata; }