Author: shawkins
Date: 2011-08-12 17:21:02 -0400 (Fri, 12 Aug 2011)
New Revision: 3380
Added:
branches/7.4.x/metadata/src/test/resources/TEIIDDES992_VDB.vdb
Modified:
branches/7.4.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
branches/7.4.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
branches/7.4.x/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java
branches/7.4.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
Log:
TEIID-1709 adding support for reading source procedure metadata as a function
Modified: branches/7.4.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2011-08-12
14:35:37 UTC (rev 3379)
+++ branches/7.4.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2011-08-12
21:21:02 UTC (rev 3380)
@@ -108,7 +108,7 @@
private Determinism determinism = Determinism.DETERMINISTIC;
@XmlElement(name="inputParameters")
- protected List<FunctionParameter> inParameters = new
ArrayList<FunctionParameter>();
+ protected List<FunctionParameter> inParameters = new
ArrayList<FunctionParameter>(2);
private FunctionParameter outputParameter;
private Schema parent;
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-08-12
14:35:37 UTC (rev 3379)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-08-12
21:21:02 UTC (rev 3380)
@@ -219,7 +219,7 @@
if (!caps.supportsFunction(function.getFunctionDescriptor().getName())) {
return false;
}
- } else if (!schema.getFullName().equalsIgnoreCase(metadata.getFullName(modelID)))
{
+ } else if (!isSameConnector(modelID, schema, metadata, capFinder)) {
return false; //not the right schema
}
Modified:
branches/7.4.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
---
branches/7.4.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2011-08-12
14:35:37 UTC (rev 3379)
+++
branches/7.4.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2011-08-12
21:21:02 UTC (rev 3380)
@@ -55,6 +55,8 @@
import org.teiid.metadata.ColumnSet;
import org.teiid.metadata.Datatype;
import org.teiid.metadata.ForeignKey;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
import org.teiid.metadata.KeyRecord;
import org.teiid.metadata.MetadataStore;
import org.teiid.metadata.Procedure;
@@ -62,6 +64,8 @@
import org.teiid.metadata.Schema;
import org.teiid.metadata.Table;
import org.teiid.metadata.VdbConstants;
+import org.teiid.metadata.FunctionMethod.Determinism;
+import org.teiid.metadata.FunctionMethod.PushDown;
import org.teiid.query.metadata.TransformationMetadata;
import org.teiid.query.metadata.TransformationMetadata.Resource;
@@ -425,6 +429,35 @@
if(transformRecord != null) {
procedureRecord.setQueryPlan(transformRecord.getTransformation());
}
+ } else if (procedureRecord.isFunction()) {
+ boolean deterministic =
Boolean.valueOf(procedureRecord.getProperties().get("deterministic"));
//$NON-NLS-1$
+ FunctionParameter outputParam = null;
+ List<FunctionParameter> args = new
ArrayList<FunctionParameter>(procedureRecord.getParameters().size() - 1);
+ boolean valid = true;
+ for (ProcedureParameter param : procedureRecord.getParameters()) {
+ FunctionParameter fp = new FunctionParameter();
+ fp.setName(param.getName());
+ fp.setDescription(param.getAnnotation());
+ fp.setType(param.getRuntimeType());
+ switch (param.getType()) {
+ case ReturnValue:
+ if (outputParam != null) {
+ valid = false;
+ }
+ outputParam = fp;
+ break;
+ case In:
+ args.add(fp);
+ break;
+ default:
+ valid = false;
+ }
+ }
+ if (valid && outputParam != null) {
+ model.addFunction(new FunctionMethod(procedureRecord.getName(),
procedureRecord.getAnnotation(), model.getName(), PushDown.MUST_PUSHDOWN,
+ null, null, args.toArray(new FunctionParameter[args.size()]), outputParam,
false, deterministic?Determinism.DETERMINISTIC:Determinism.NONDETERMINISTIC));
+ continue;
+ }
}
model.addProcedure(procedureRecord);
}
Modified:
branches/7.4.x/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java
===================================================================
---
branches/7.4.x/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java 2011-08-12
14:35:37 UTC (rev 3379)
+++
branches/7.4.x/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java 2011-08-12
21:21:02 UTC (rev 3380)
@@ -27,9 +27,11 @@
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.Collection;
+import java.util.Map;
import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.Schema;
import org.teiid.metadata.Table;
import org.teiid.query.metadata.TransformationMetadata;
@@ -63,4 +65,13 @@
assertNotNull(schema.getFunctions());
}
+ @Test public void testFunctionMetadata() throws Exception {
+ TransformationMetadata tm =
VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() +
"/TEIIDDES992_VDB.vdb");
+ Map<String, FunctionMethod> functions =
tm.getMetadataStore().getSchema("TEIIDDES992").getFunctions();
+ assertEquals(1, functions.size());
+ FunctionMethod fm = functions.values().iterator().next();
+ assertEquals("sampleFunction", fm.getName());
+ assertEquals(1, fm.getInputParameters().size());
+ }
+
}
Added: branches/7.4.x/metadata/src/test/resources/TEIIDDES992_VDB.vdb
===================================================================
(Binary files differ)
Property changes on: branches/7.4.x/metadata/src/test/resources/TEIIDDES992_VDB.vdb
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: branches/7.4.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2011-08-12
14:35:37 UTC (rev 3379)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2011-08-12
21:21:02 UTC (rev 3380)
@@ -170,7 +170,6 @@
mergedUDF.addFunctions(this.udf);
}
if (this.stores != null) {
- //schema scoped source functions - this is only a dynamic vdb concept
for(MetadataStore store:this.stores.getStores()) {
for (Schema schema:store.getSchemas().values()) {
Collection<FunctionMethod> funcs = schema.getFunctions().values();