use of org.teiid.query.mapping.relational.QueryNode in project teiid by teiid.
the class TestValidator method exampleMetadata.
public static TransformationMetadata exampleMetadata() {
MetadataStore metadataStore = new MetadataStore();
// Create metadata objects
// $NON-NLS-1$
Schema modelObj = RealMetadataFactory.createPhysicalModel("test", metadataStore);
// $NON-NLS-1$
Schema vModelObj2 = RealMetadataFactory.createVirtualModel("vTest", metadataStore);
// $NON-NLS-1$
Table groupObj = RealMetadataFactory.createPhysicalGroup("group", modelObj);
// $NON-NLS-1$
Column elemObj0 = RealMetadataFactory.createElement("e0", groupObj, DataTypeManager.DefaultDataTypes.INTEGER);
elemObj0.setNullType(NullType.No_Nulls);
// $NON-NLS-1$
Column elemObj1 = RealMetadataFactory.createElement("e1", groupObj, DataTypeManager.DefaultDataTypes.STRING);
elemObj1.setSelectable(false);
// $NON-NLS-1$
Column elemObj2 = RealMetadataFactory.createElement("e2", groupObj, DataTypeManager.DefaultDataTypes.STRING);
elemObj2.setSearchType(SearchType.Like_Only);
// $NON-NLS-1$
Column elemObj3 = RealMetadataFactory.createElement("e3", groupObj, DataTypeManager.DefaultDataTypes.STRING);
elemObj3.setSearchType(SearchType.All_Except_Like);
// $NON-NLS-1$
Table group2Obj = RealMetadataFactory.createPhysicalGroup("group2", modelObj);
// $NON-NLS-1$
Column elemObj2_0 = RealMetadataFactory.createElement("e0", group2Obj, DataTypeManager.DefaultDataTypes.INTEGER);
elemObj2_0.setUpdatable(false);
// $NON-NLS-1$
RealMetadataFactory.createElement("e1", group2Obj, DataTypeManager.DefaultDataTypes.STRING);
// $NON-NLS-1$
Column elemObj2_2 = RealMetadataFactory.createElement("e2", group2Obj, DataTypeManager.DefaultDataTypes.STRING);
elemObj2_2.setUpdatable(false);
// $NON-NLS-1$
Table group3Obj = RealMetadataFactory.createPhysicalGroup("group3", modelObj);
group3Obj.setSupportsUpdate(false);
// $NON-NLS-1$
RealMetadataFactory.createElement("e0", group3Obj, DataTypeManager.DefaultDataTypes.INTEGER);
// $NON-NLS-1$
RealMetadataFactory.createElement("e1", group3Obj, DataTypeManager.DefaultDataTypes.STRING);
// $NON-NLS-1$
RealMetadataFactory.createElement("e2", group3Obj, DataTypeManager.DefaultDataTypes.STRING);
// Create virtual group & elements.
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vNode = new QueryNode("SELECT * FROM test.group WHERE e2 = 'x'");
// $NON-NLS-1$
Table vGroup = RealMetadataFactory.createVirtualGroup("vGroup", vModelObj2, vNode);
RealMetadataFactory.createElements(vGroup, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e0", "e1", "e2", "e3" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vNode2 = new QueryNode("SELECT * FROM test.group");
// $NON-NLS-1$
Table vGroup2 = RealMetadataFactory.createVirtualGroup("vMap", vModelObj2, vNode2);
List<Column> vGroupE2 = RealMetadataFactory.createElements(vGroup2, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e0", "e1", "e2", "e3" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
vGroupE2.get(0).setNullType(NullType.No_Nulls);
vGroupE2.get(1).setSelectable(false);
vGroupE2.get(2).setSearchType(SearchType.Like_Only);
vGroupE2.get(3).setSearchType(SearchType.All_Except_Like);
return RealMetadataFactory.createTransformationMetadata(metadataStore, "example");
}
use of org.teiid.query.mapping.relational.QueryNode 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.query.mapping.relational.QueryNode in project teiid by teiid.
the class TestProcessor method testInsertTempTableCreation1.
@Test
public void testInsertTempTableCreation1() {
MetadataStore metadataStore = new MetadataStore();
// $NON-NLS-1$
Schema v1 = RealMetadataFactory.createVirtualModel("v1", metadataStore);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode n1 = new QueryNode("CREATE VIRTUAL PROCEDURE BEGIN insert into #temp (var1) values (1); select 2 as var1 into #temp; select #temp.var1 from #temp; END");
// $NON-NLS-1$ //$NON-NLS-2$
ColumnSet<Procedure> rs = RealMetadataFactory.createResultSet("rs", new String[] { "var1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
// $NON-NLS-1$
Procedure vp = RealMetadataFactory.createVirtualProcedure("vp", v1, null, n1);
vp.setResultSet(rs);
QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(metadataStore, "foo");
// $NON-NLS-1$
ProcessorPlan plan = helpGetPlan("exec v1.vp()", metadata);
List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(1) }), Arrays.asList(new Object[] { new Integer(2) }) };
helpProcess(plan, new FakeDataManager(), expected);
}
use of org.teiid.query.mapping.relational.QueryNode in project teiid by teiid.
the class TestProcessor method createProjectErrorMetadata.
private TransformationMetadata createProjectErrorMetadata() {
MetadataStore metadataStore = new MetadataStore();
// $NON-NLS-1$
Schema p1 = RealMetadataFactory.createPhysicalModel("p1", metadataStore);
// $NON-NLS-1$
Table t1 = RealMetadataFactory.createPhysicalGroup("t", p1);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
RealMetadataFactory.createElements(t1, new String[] { "a", "b" }, new String[] { "string", "string" });
// $NON-NLS-1$
Schema v1 = RealMetadataFactory.createVirtualModel("v1", metadataStore);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode n1 = new QueryNode("SELECT convert(a, integer) as c, b FROM p1.t");
// $NON-NLS-1$
Table vt1 = RealMetadataFactory.createVirtualGroup("t1", v1, n1);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
RealMetadataFactory.createElements(vt1, new String[] { "c", "b" }, new String[] { "integer", "string" });
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode n3 = new QueryNode("SELECT c, b FROM v1.t1 UNION ALL SELECT c, b FROM v1.t1");
// $NON-NLS-1$
Table vu1 = RealMetadataFactory.createVirtualGroup("u1", v1, n3);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
RealMetadataFactory.createElements(vu1, new String[] { "c", "b" }, new String[] { "integer", "string" });
return RealMetadataFactory.createTransformationMetadata(metadataStore, "projectError");
}
use of org.teiid.query.mapping.relational.QueryNode in project teiid by teiid.
the class TestProcessor method testInsertTempTableCreation.
/*
* Prior to case 3994 testInsertTempTableCreation1 worked, but testInsertTempTableCreation did not.
* Now they should both pass
*
*/
@Test
public void testInsertTempTableCreation() {
MetadataStore metadataStore = new MetadataStore();
// $NON-NLS-1$
Schema v1 = RealMetadataFactory.createVirtualModel("v1", metadataStore);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode n1 = new QueryNode("CREATE VIRTUAL PROCEDURE BEGIN insert into #temp (var1) values (1); select #temp.var1 from #temp; END");
// $NON-NLS-1$ //$NON-NLS-2$
ColumnSet<Procedure> rs = RealMetadataFactory.createResultSet("rs", new String[] { "var1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
// $NON-NLS-1$
Procedure vp = RealMetadataFactory.createVirtualProcedure("vp", v1, null, n1);
vp.setResultSet(rs);
QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(metadataStore, "foo");
// $NON-NLS-1$
ProcessorPlan plan = helpGetPlan("exec v1.vp()", metadata);
List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(1) }) };
helpProcess(plan, new FakeDataManager(), expected);
}
Aggregations