use of org.teiid.metadata.ProcedureParameter in project teiid by teiid.
the class TestODataMetadataProcessor method testAction.
@Test
public void testAction() throws Exception {
CsdlReturnType returnType = new CsdlReturnType();
returnType.setType("Edm.String");
MetadataFactory mf = actionMetadata("invoke", returnType, null);
Procedure p = mf.getSchema().getProcedure("invoke");
assertNotNull(p);
assertEquals(3, p.getParameters().size());
assertNull(p.getResultSet());
assertNotNull(getReturnParameter(p));
ProcedureParameter pp = getReturnParameter(p);
assertEquals("string", pp.getRuntimeType());
ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
assertEquals(ODataType.ACTION, type);
}
use of org.teiid.metadata.ProcedureParameter in project teiid by teiid.
the class TestODataMetadataProcessor method testFunctionReturnPrimitiveCollection.
@Test
public void testFunctionReturnPrimitiveCollection() throws Exception {
CsdlReturnType returnType = new CsdlReturnType();
returnType.setType("Edm.String");
returnType.setCollection(true);
MetadataFactory mf = functionMetadata("invoke", returnType, null);
Procedure p = mf.getSchema().getProcedure("invoke");
assertNotNull(p);
assertEquals(3, p.getParameters().size());
assertNull(p.getResultSet());
assertNotNull(getReturnParameter(p));
ProcedureParameter pp = getReturnParameter(p);
assertEquals("string[]", pp.getRuntimeType());
ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
assertEquals(ODataType.FUNCTION, type);
}
use of org.teiid.metadata.ProcedureParameter in project teiid by teiid.
the class TestValidator method helpCreateCase4237VirtualProcedureMetadata.
/**
* Create fake metadata for this case. Need a physical stored procedure and
* a virtual stored procedure which calls the physical one.
* @return
*/
private TransformationMetadata helpCreateCase4237VirtualProcedureMetadata() {
MetadataStore metadataStore = new MetadataStore();
// $NON-NLS-1$
Schema physicalModel = RealMetadataFactory.createPhysicalModel("pm1", metadataStore);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ColumnSet<Procedure> resultSet = RealMetadataFactory.createResultSet("pm1.rs", new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
// $NON-NLS-1$
ProcedureParameter inParam = RealMetadataFactory.createParameter("in", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING);
// $NON-NLS-1$ //$NON-NLS-2$
Procedure storedProcedure = RealMetadataFactory.createStoredProcedure("sp", physicalModel, Arrays.asList(inParam));
storedProcedure.setResultSet(resultSet);
// $NON-NLS-1$
Schema virtualModel = RealMetadataFactory.createVirtualModel("vm1", metadataStore);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ColumnSet<Procedure> virtualResultSet = RealMetadataFactory.createResultSet("vm1.rs", new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
// $NON-NLS-1$
ProcedureParameter virtualInParam = RealMetadataFactory.createParameter("in1", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode queryNode = new QueryNode("CREATE VIRTUAL PROCEDURE BEGIN EXEC pm1.sp(vm1.sp.in1); END");
// $NON-NLS-1$
Procedure virtualStoredProcedure = RealMetadataFactory.createVirtualProcedure("sp", virtualModel, Arrays.asList(virtualInParam), queryNode);
virtualStoredProcedure.setResultSet(virtualResultSet);
return RealMetadataFactory.createTransformationMetadata(metadataStore, "case4237");
}
use of org.teiid.metadata.ProcedureParameter in project teiid by teiid.
the class TestDynamicImportedMetaData method testDDLMetadata.
@Test
public void testDDLMetadata() throws Exception {
String ddl = "CREATE FOREIGN PROCEDURE getTextFiles(IN pathAndPattern varchar) RETURNS (file clob, filpath string) OPTIONS(UUID 'uuid')";
MetadataFactory mf = createMetadataFactory("MarketData", new Properties());
QueryParser.getQueryParser().parseDDL(mf, ddl);
MetadataStore ms = mf.asMetadataStore();
String ddl2 = "CREATE VIEW stock (symbol string, price bigdecimal) OPTIONS (UUID 'uuid')" + "AS select stock.* from (call MarketData.getTextFiles('*.txt')) f, " + "TEXTTABLE(f.file COLUMNS symbol string, price bigdecimal HEADER) stock;";
MetadataFactory m2 = createMetadataFactory("portfolio", new Properties());
QueryParser.getQueryParser().parseDDL(m2, ddl2);
m2.getSchema().setPhysical(false);
m2.mergeInto(ms);
server.deployVDB("test", ms);
// $NON-NLS-1$
Connection conn = server.createConnection("jdbc:teiid:test");
Properties props = new Properties();
props.setProperty("importer.importProcedures", Boolean.TRUE.toString());
MetadataStore store = getMetadata(props, conn).asMetadataStore();
Procedure p = store.getSchema("test").getProcedure("test.MarketData.getTextFiles");
assertNotNull(p);
ProcedureParameter pp = p.getParameters().get(0);
assertEquals("pathAndPattern", pp.getName());
assertEquals("\"pathAndPattern\"", pp.getNameInSource());
assertEquals(ProcedureParameter.Type.In, pp.getType());
// assertEquals("string", pp.getDatatype().getName());
Table t = store.getSchema("test").getTable("test.portfolio.stock");
assertNotNull(t);
List<Column> columns = t.getColumns();
assertEquals(2, columns.size());
assertEquals("symbol", columns.get(0).getName());
assertEquals("price", columns.get(1).getName());
}
use of org.teiid.metadata.ProcedureParameter in project teiid by teiid.
the class TestProcedure method checkParams.
private List<ProcedureParameter> checkParams(Procedure proc, String[] nameInSource, ProcedureParameter.Type[] direction, int[] index, Class<?>[] type) {
List<ProcedureParameter> params = proc.getParameters();
assertEquals(type.length, params.size());
for (int i = 0; i < params.size(); i++) {
ProcedureParameter param = params.get(i);
assertEquals(nameInSource[i], param.getNameInSource());
assertEquals(direction[i], param.getType());
assertEquals(index[i], param.getPosition());
assertEquals(type[i], param.getJavaType());
}
return params;
}
Aggregations