use of org.teiid.metadata.ProcedureParameter in project teiid by teiid.
the class S3ExecutionFactory method deleteFile.
private void deleteFile(MetadataFactory metadataFactory) {
Procedure p = metadataFactory.addProcedure(DELETEFILE);
// $NON-NLS-1$
p.setAnnotation("Delete the given file from bucket.");
// $NON-NLS-1$
ProcedureParameter param = metadataFactory.addProcedureParameter("name", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
// $NON-NLS-1$
param.setAnnotation("Name of the file");
addCommonParameters(metadataFactory, p);
}
use of org.teiid.metadata.ProcedureParameter in project teiid by teiid.
the class S3ExecutionFactory method addCommonParameters.
private void addCommonParameters(MetadataFactory metadataFactory, Procedure p) {
ProcedureParameter param;
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("bucket", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
// $NON-NLS-1$
param.setAnnotation("The name of the bucket in Amazon S3");
param.setNullType(NullType.Nullable);
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("region", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
// $NON-NLS-1$
param.setAnnotation("region in which the bucket exists on Amazon S3");
param.setNullType(NullType.Nullable);
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("endpoint", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
// $NON-NLS-1$
param.setAnnotation("Endpoint point of the Object, if provided this overwirtes the name and bucket properties");
param.setNullType(NullType.Nullable);
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("accesskey", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
// $NON-NLS-1$
param.setAnnotation("Security Access Key, if not provided will use translator configured keys.");
param.setNullType(NullType.Nullable);
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("secretkey", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
// $NON-NLS-1$
param.setAnnotation("Security Secret Key, if not provided will use translator configured keys.");
param.setNullType(NullType.Nullable);
}
use of org.teiid.metadata.ProcedureParameter in project teiid by teiid.
the class FileExecutionFactory method getMetadata.
@Override
public void getMetadata(MetadataFactory metadataFactory, Connection connection) throws TranslatorException {
Procedure p = metadataFactory.addProcedure(GETTEXTFILES);
// $NON-NLS-1$
p.setAnnotation("Returns text files that match the given path and pattern as CLOBs");
// $NON-NLS-1$
ProcedureParameter param = metadataFactory.addProcedureParameter("pathAndPattern", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
// $NON-NLS-1$
param.setAnnotation("The path and pattern of what files to return. Currently the only pattern supported is *.<ext>, which returns only the files matching the given extension at the given path.");
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("file", TypeFacility.RUNTIME_NAMES.CLOB, p);
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("filePath", TypeFacility.RUNTIME_NAMES.STRING, p);
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("lastModified", TypeFacility.RUNTIME_NAMES.TIMESTAMP, p);
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("created", TypeFacility.RUNTIME_NAMES.TIMESTAMP, p);
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("size", TypeFacility.RUNTIME_NAMES.LONG, p);
Procedure p1 = metadataFactory.addProcedure(GETFILES);
// $NON-NLS-1$
p1.setAnnotation("Returns files that match the given path and pattern as BLOBs");
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("pathAndPattern", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p1);
// $NON-NLS-1$
param.setAnnotation("The path and pattern of what files to return. Currently the only pattern supported is *.<ext>, which returns only the files matching the given extension at the given path.");
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("file", TypeFacility.RUNTIME_NAMES.BLOB, p1);
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("filePath", TypeFacility.RUNTIME_NAMES.STRING, p1);
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("lastModified", TypeFacility.RUNTIME_NAMES.TIMESTAMP, p1);
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("created", TypeFacility.RUNTIME_NAMES.TIMESTAMP, p1);
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("size", TypeFacility.RUNTIME_NAMES.LONG, p1);
Procedure p2 = metadataFactory.addProcedure(SAVEFILE);
// $NON-NLS-1$
p2.setAnnotation("Saves the given value to the given path. Any existing file will be overriden.");
// $NON-NLS-1$
metadataFactory.addProcedureParameter("filePath", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p2);
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("file", TypeFacility.RUNTIME_NAMES.OBJECT, Type.In, p2);
// $NON-NLS-1$
param.setAnnotation("The contents to save. Can be one of CLOB, BLOB, or XML");
Procedure p3 = metadataFactory.addProcedure(DELETEFILE);
// $NON-NLS-1$
p3.setAnnotation("Delete the given file path. ");
// $NON-NLS-1$
metadataFactory.addProcedureParameter("filePath", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p3);
}
use of org.teiid.metadata.ProcedureParameter in project teiid by teiid.
the class TestProcedureRelational method testParameterPassing.
/**
* test for defect 22376
*/
@Test
public void testParameterPassing() throws Exception {
MetadataStore metadataStore = new MetadataStore();
// $NON-NLS-1$
Schema v1 = RealMetadataFactory.createVirtualModel("v1", metadataStore);
// $NON-NLS-1$ //$NON-NLS-2$
ColumnSet<Procedure> rs1 = RealMetadataFactory.createResultSet("v1.rs1", new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
// $NON-NLS-1$
QueryNode n1 = new QueryNode("CREATE VIRTUAL PROCEDURE BEGIN declare string VARIABLES.x = '1'; SELECT e1 FROM v1.vp2 where v1.vp2.in = VARIABLES.x; END");
// $NON-NLS-1$
Procedure vt1 = RealMetadataFactory.createVirtualProcedure("vp1", v1, null, n1);
vt1.setResultSet(rs1);
// $NON-NLS-1$
ProcedureParameter p1 = RealMetadataFactory.createParameter("in", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING);
// $NON-NLS-1$
QueryNode n2 = new QueryNode("CREATE VIRTUAL PROCEDURE BEGIN declare string VARIABLES.x; declare string VARIABLES.y; VARIABLES.x = '2'; VARIABLES.y = v1.vp2.in; select VARIABLES.y; end");
// $NON-NLS-1$
Procedure vt2 = RealMetadataFactory.createVirtualProcedure("vp2", v1, Arrays.asList(p1), n2);
vt2.setResultSet(RealMetadataFactory.createResultSet("v1.rs1", new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }));
// $NON-NLS-1$
String sql = "select * from (exec v1.vp1()) foo";
List<?>[] expected = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "1" }) };
QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(metadataStore, "foo");
// Construct data manager with data
// Plan query
ProcessorPlan plan = TestProcedureProcessor.getProcedurePlan(sql, metadata);
// Run query
TestProcedureProcessor.helpTestProcess(plan, expected, new FakeDataManager(), metadata);
}
use of org.teiid.metadata.ProcedureParameter in project teiid by teiid.
the class TestProcedureProcessor method testFunctionInput.
/**
* defect 23975
*/
@Test
public void testFunctionInput() throws Exception {
MetadataStore metadataStore = new MetadataStore();
// $NON-NLS-1$
Schema v1 = RealMetadataFactory.createVirtualModel("v1", metadataStore);
// $NON-NLS-1$
ProcedureParameter p1 = RealMetadataFactory.createParameter("in", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING);
// $NON-NLS-1$ //$NON-NLS-2$
ColumnSet<Procedure> rs1 = RealMetadataFactory.createResultSet("v1.rs1", new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode n1 = new QueryNode("CREATE VIRTUAL PROCEDURE BEGIN declare string VARIABLES.x = '1'; exec v1.vp2(concat(x, v1.vp1.in)); END");
// $NON-NLS-1$
Procedure vt1 = RealMetadataFactory.createVirtualProcedure("vp1", v1, Arrays.asList(p1), n1);
vt1.setResultSet(rs1);
// $NON-NLS-1$
ProcedureParameter p2 = RealMetadataFactory.createParameter("in", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode n2 = new QueryNode("CREATE VIRTUAL PROCEDURE BEGIN select v1.vp2.in; end");
// $NON-NLS-1$
Procedure vt2 = RealMetadataFactory.createVirtualProcedure("vp2", v1, Arrays.asList(p2), n2);
// $NON-NLS-1$ //$NON-NLS-2$
vt2.setResultSet(RealMetadataFactory.createResultSet("v1.rs1", new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }));
// $NON-NLS-1$
String sql = "exec v1.vp1('1')";
List[] expected = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "11" }) };
QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(metadataStore, "foo");
// Construct data manager with data
// Plan query
ProcessorPlan plan = getProcedurePlan(sql, metadata);
// Run query
helpTestProcess(plan, expected, new FakeDataManager(), metadata);
}
Aggregations