use of org.teiid.query.mapping.relational.QueryNode in project teiid by teiid.
the class TransformationMetadata method getStoredProcInfoDirect.
private StoredProcedureInfo getStoredProcInfoDirect(final String name) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isNotEmpty(name);
String canonicalName = name.toUpperCase();
Collection<StoredProcedureInfo> results = this.procedureCache.get(canonicalName);
if (results == null) {
Collection<Procedure> procRecords = getMetadataStore().getStoredProcedure(canonicalName);
if (procRecords.isEmpty()) {
return null;
}
results = new ArrayList<StoredProcedureInfo>(procRecords.size());
for (Procedure procRecord : procRecords) {
String procedureFullName = procRecord.getFullName();
// create the storedProcedure info object that would hold procedure's metadata
StoredProcedureInfo procInfo = new StoredProcedureInfo();
procInfo.setProcedureCallableName(procedureFullName);
procInfo.setProcedureID(procRecord);
// modelID for the procedure
procInfo.setModelID(procRecord.getParent());
// get the parameter metadata info
for (ProcedureParameter paramRecord : procRecord.getParameters()) {
String runtimeType = paramRecord.getRuntimeType();
int direction = this.convertParamRecordTypeToStoredProcedureType(paramRecord.getType());
// create a parameter and add it to the procedure object
SPParameter spParam = new SPParameter(paramRecord.getPosition(), direction, paramRecord.getFullName());
spParam.setMetadataID(paramRecord);
spParam.setClassType(DataTypeManager.getDataTypeClass(runtimeType));
if (paramRecord.isVarArg()) {
spParam.setVarArg(true);
spParam.setClassType(DataTypeManager.getArrayType(spParam.getClassType()));
}
procInfo.addParameter(spParam);
}
// if the procedure returns a resultSet, obtain resultSet metadata
if (procRecord.getResultSet() != null) {
ColumnSet<Procedure> resultRecord = procRecord.getResultSet();
// resultSet is the last parameter in the procedure
int lastParamIndex = procInfo.getParameters().size() + 1;
SPParameter param = new SPParameter(lastParamIndex, SPParameter.RESULT_SET, resultRecord.getFullName());
param.setClassType(java.sql.ResultSet.class);
param.setMetadataID(resultRecord);
for (Column columnRecord : resultRecord.getColumns()) {
String colType = columnRecord.getRuntimeType();
param.addResultSetColumn(columnRecord.getFullName(), DataTypeManager.getDataTypeClass(colType), columnRecord);
}
procInfo.addParameter(param);
}
// if this is a virtual procedure get the procedure plan
if (procRecord.isVirtual()) {
QueryNode queryNode = new LiveQueryNode(procRecord);
procInfo.setQueryPlan(queryNode);
}
procInfo.setUpdateCount(procRecord.getUpdateCount());
results.add(procInfo);
}
this.procedureCache.put(canonicalName, results);
}
StoredProcedureInfo result = null;
for (StoredProcedureInfo storedProcedureInfo : results) {
Schema schema = (Schema) storedProcedureInfo.getModelID();
if (name.equalsIgnoreCase(storedProcedureInfo.getProcedureCallableName()) || vdbMetaData == null || vdbMetaData.isVisible(schema.getName())) {
if (result != null) {
throw new QueryMetadataException(QueryPlugin.Event.TEIID30358, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30358, name));
}
result = storedProcedureInfo;
}
}
return result;
}
use of org.teiid.query.mapping.relational.QueryNode in project teiid by teiid.
the class TestHiveExecutionFactory method exampleBQT.
public static TransformationMetadata exampleBQT() {
MetadataStore metadataStore = new MetadataStore();
// $NON-NLS-1$
Schema bqt1 = RealMetadataFactory.createPhysicalModel("BQT1", metadataStore);
// $NON-NLS-1$
Table bqt1SmallA = RealMetadataFactory.createPhysicalGroup("SmallA", bqt1);
// $NON-NLS-1$
Table bqt1SmallB = RealMetadataFactory.createPhysicalGroup("SmallB", bqt1);
String[] elemNames = new String[] { // $NON-NLS-1$ //$NON-NLS-2$
"IntKey", // $NON-NLS-1$ //$NON-NLS-2$
"StringKey", // $NON-NLS-1$ //$NON-NLS-2$
"IntNum", // $NON-NLS-1$ //$NON-NLS-2$
"StringNum", // $NON-NLS-1$ //$NON-NLS-2$
"FloatNum", // $NON-NLS-1$ //$NON-NLS-2$
"LongNum", // $NON-NLS-1$ //$NON-NLS-2$
"DoubleNum", // $NON-NLS-1$ //$NON-NLS-2$
"ByteNum", // $NON-NLS-1$ //$NON-NLS-2$
"DateValue", // $NON-NLS-1$ //$NON-NLS-2$
"TimeValue", // $NON-NLS-1$ //$NON-NLS-2$
"TimestampValue", // $NON-NLS-1$ //$NON-NLS-2$
"BooleanValue", // $NON-NLS-1$ //$NON-NLS-2$
"CharValue", // $NON-NLS-1$ //$NON-NLS-2$
"ShortValue", // $NON-NLS-1$ //$NON-NLS-2$
"BigIntegerValue", // $NON-NLS-1$ //$NON-NLS-2$
"BigDecimalValue", // $NON-NLS-1$
"ObjectValue" };
String[] nativeTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE, DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.SHORT, DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.STRING };
String[] runtimeTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE, DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.CHAR, DataTypeManager.DefaultDataTypes.SHORT, DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, DataTypeManager.DefaultDataTypes.OBJECT };
List<Column> bqt1SmallAe = RealMetadataFactory.createElements(bqt1SmallA, elemNames, nativeTypes);
List<Column> bqt1SmallBe = RealMetadataFactory.createElements(bqt1SmallB, elemNames, nativeTypes);
// $NON-NLS-1$
Schema vqt = RealMetadataFactory.createVirtualModel("VQT", metadataStore);
// $NON-NLS-1$
QueryNode vqtn1 = new QueryNode("SELECT * FROM BQT1.SmallA");
// $NON-NLS-1$
Table vqtg1 = RealMetadataFactory.createUpdatableVirtualGroup("SmallA", vqt, vqtn1);
RealMetadataFactory.createElements(vqtg1, elemNames, runtimeTypes);
// $NON-NLS-1$
return RealMetadataFactory.createTransformationMetadata(metadataStore, "bqt");
}
use of org.teiid.query.mapping.relational.QueryNode in project teiid by teiid.
the class TestOptimizer method example1.
public static TransformationMetadata example1() {
MetadataStore metadataStore = new MetadataStore();
// Create models
// $NON-NLS-1$
Schema pm1 = RealMetadataFactory.createPhysicalModel("pm1", metadataStore);
// $NON-NLS-1$
Schema pm2 = RealMetadataFactory.createPhysicalModel("pm2", metadataStore);
// $NON-NLS-1$
Schema vm1 = RealMetadataFactory.createVirtualModel("vm1", metadataStore);
// Create physical groups
// $NON-NLS-1$
Table pm1g1 = RealMetadataFactory.createPhysicalGroup("g1", pm1);
// $NON-NLS-1$
Table pm1g2 = RealMetadataFactory.createPhysicalGroup("g2", pm1);
// $NON-NLS-1$
Table pm1g3 = RealMetadataFactory.createPhysicalGroup("g3", pm1);
// $NON-NLS-1$
Table pm1g4 = RealMetadataFactory.createPhysicalGroup("g4", pm1);
// $NON-NLS-1$
Table pm1g5 = RealMetadataFactory.createPhysicalGroup("g5", pm1);
// $NON-NLS-1$
Table pm1g6 = RealMetadataFactory.createPhysicalGroup("g6", pm1);
// $NON-NLS-1$
Table pm1g7 = RealMetadataFactory.createPhysicalGroup("g7", pm1);
// $NON-NLS-1$
Table pm1g8 = RealMetadataFactory.createPhysicalGroup("g8", pm1);
// $NON-NLS-1$
Table pm2g1 = RealMetadataFactory.createPhysicalGroup("g1", pm2);
// $NON-NLS-1$
Table pm2g2 = RealMetadataFactory.createPhysicalGroup("g2", pm2);
// $NON-NLS-1$
Table pm2g3 = RealMetadataFactory.createPhysicalGroup("g3", pm2);
// Create physical elements
RealMetadataFactory.createElements(pm1g1, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(pm1g2, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(pm1g3, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(pm1g4, // $NON-NLS-1$
new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(pm1g5, // $NON-NLS-1$
new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(pm1g6, // $NON-NLS-1$
new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(pm1g7, // $NON-NLS-1$
new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(pm1g8, // $NON-NLS-1$
new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(pm2g1, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(pm2g2, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(pm2g3, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
// Create virtual groups
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1g1n1 = new QueryNode("SELECT * FROM pm1.g1");
// $NON-NLS-1$
Table vm1g1 = RealMetadataFactory.createUpdatableVirtualGroup("g1", vm1, vm1g1n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1g2n1 = new QueryNode("SELECT * FROM pm1.g1");
// $NON-NLS-1$
Table vm1g2 = RealMetadataFactory.createUpdatableVirtualGroup("g2", vm1, vm1g2n1);
// defect 8096
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1sub1n1 = new QueryNode("SELECT * FROM vm1.g1 WHERE e1 IN /*+ no_unnest */ (SELECT e1 FROM vm1.g3)");
// $NON-NLS-1$
Table vm1sub1 = RealMetadataFactory.createVirtualGroup("sub1", vm1, vm1sub1n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1g3n1 = new QueryNode("SELECT * FROM pm1.g2");
// $NON-NLS-1$
Table vm1g3 = RealMetadataFactory.createUpdatableVirtualGroup("g3", vm1, vm1g3n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1g4n1 = new QueryNode("SELECT pm1.g1.e1, g2.e1 FROM pm1.g1, pm1.g2 g2 WHERE pm1.g1.e1= g2.e1");
// $NON-NLS-1$
Table vm1g4 = RealMetadataFactory.createUpdatableVirtualGroup("g4", vm1, vm1g4n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1g5n1 = new QueryNode("SELECT DISTINCT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1");
// $NON-NLS-1$
Table vm1g5 = RealMetadataFactory.createUpdatableVirtualGroup("g5", vm1, vm1g5n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1g6n1 = new QueryNode("SELECT e1, convert(e2, string), 3 as e3, ((e2+e4)/3) as e4 FROM pm1.g1");
// $NON-NLS-1$
Table vm1g6 = RealMetadataFactory.createUpdatableVirtualGroup("g6", vm1, vm1g6n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1u1n1 = new QueryNode("SELECT * FROM pm1.g1 UNION SELECT * FROM pm1.g2 UNION ALL SELECT * FROM pm1.g3");
// $NON-NLS-1$
Table vm1u1 = RealMetadataFactory.createUpdatableVirtualGroup("u1", vm1, vm1u1n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1u2n1 = new QueryNode("SELECT * FROM pm1.g1 UNION SELECT * FROM pm1.g2");
// $NON-NLS-1$
Table vm1u2 = RealMetadataFactory.createUpdatableVirtualGroup("u2", vm1, vm1u2n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1u3n1 = new QueryNode("SELECT e1 FROM pm1.g1 UNION SELECT convert(e2, string) as x FROM pm1.g2");
// $NON-NLS-1$
Table vm1u3 = RealMetadataFactory.createUpdatableVirtualGroup("u3", vm1, vm1u3n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1u4n1 = new QueryNode("SELECT concat(e1, 'x') as v1 FROM pm1.g1 UNION ALL SELECT e1 FROM pm1.g2");
// $NON-NLS-1$
Table vm1u4 = RealMetadataFactory.createUpdatableVirtualGroup("u4", vm1, vm1u4n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1u5n1 = new QueryNode("SELECT concat(e1, 'x') as v1 FROM pm1.g1 UNION ALL SELECT concat('a', e1) FROM pm1.g2");
// $NON-NLS-1$
Table vm1u5 = RealMetadataFactory.createUpdatableVirtualGroup("u5", vm1, vm1u5n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1u6n1 = new QueryNode("SELECT x1.e1 AS elem, 'xyz' AS const FROM pm1.g1 AS x1");
// $NON-NLS-1$
Table vm1u6 = RealMetadataFactory.createUpdatableVirtualGroup("u6", vm1, vm1u6n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1u7n1 = new QueryNode("SELECT 's1' AS const, e1 FROM pm1.g1 UNION ALL SELECT 's2', e1 FROM pm1.g2");
// $NON-NLS-1$
Table vm1u7 = RealMetadataFactory.createUpdatableVirtualGroup("u7", vm1, vm1u7n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1u8n1 = new QueryNode("SELECT const, e1 FROM vm1.u7 UNION ALL SELECT 's3', e1 FROM pm1.g3");
// $NON-NLS-1$
Table vm1u8 = RealMetadataFactory.createUpdatableVirtualGroup("u8", vm1, vm1u8n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1u9n1 = new QueryNode("SELECT e1 as a, e1 as b FROM pm1.g1 UNION ALL SELECT e1, e1 FROM pm1.g2");
// $NON-NLS-1$
Table vm1u9 = RealMetadataFactory.createUpdatableVirtualGroup("u9", vm1, vm1u9n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1a1n1 = new QueryNode("SELECT e1, SUM(e2) AS sum_e2 FROM pm1.g1 GROUP BY e1");
// $NON-NLS-1$
Table vm1a1 = RealMetadataFactory.createUpdatableVirtualGroup("a1", vm1, vm1a1n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1a2n1 = new QueryNode("SELECT e1, SUM(e2) AS sum_e2 FROM pm1.g1 GROUP BY e1 HAVING SUM(e2) > 5");
// $NON-NLS-1$
Table vm1a2 = RealMetadataFactory.createUpdatableVirtualGroup("a2", vm1, vm1a2n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1a3n1 = new QueryNode("SELECT SUM(e2) AS sum_e2 FROM pm1.g1");
// $NON-NLS-1$
Table vm1a3 = RealMetadataFactory.createUpdatableVirtualGroup("a3", vm1, vm1a3n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1a4n1 = new QueryNode("SELECT COUNT(*) FROM pm1.g1");
// $NON-NLS-1$
Table vm1a4 = RealMetadataFactory.createUpdatableVirtualGroup("a4", vm1, vm1a4n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1a5n1 = new QueryNode("SELECT vm1.a4.count FROM vm1.a4 UNION ALL SELECT COUNT(*) FROM pm1.g1");
// $NON-NLS-1$
Table vm1a5 = RealMetadataFactory.createUpdatableVirtualGroup("a5", vm1, vm1a5n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1a6n1 = new QueryNode("SELECT COUNT(*) FROM vm1.u2");
// $NON-NLS-1$
Table vm1a6 = RealMetadataFactory.createUpdatableVirtualGroup("a6", vm1, vm1a6n1);
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1g7n1 = new QueryNode("select DECODESTRING(e1, 'S,Pay,P,Rec') as e1, e2 FROM pm1.g1");
// $NON-NLS-1$
Table vm1g7 = RealMetadataFactory.createVirtualGroup("g7", vm1, vm1g7n1);
// Create virtual elements
RealMetadataFactory.createElements(vm1g1, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(vm1g2, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(vm1g3, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
// for defect 8096
RealMetadataFactory.createElements(vm1sub1, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(vm1g4, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(vm1g5, // $NON-NLS-1$
new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(vm1g6, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(vm1g7, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
RealMetadataFactory.createElements(vm1u1, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(vm1u2, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(vm1u3, // $NON-NLS-1$
new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(vm1u4, // $NON-NLS-1$
new String[] { "v1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(vm1u5, // $NON-NLS-1$
new String[] { "v1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(vm1u6, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "elem", "const" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(vm1u7, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "const", "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(vm1u8, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "const", "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(vm1u9, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "a", "b" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
RealMetadataFactory.createElements(vm1a1, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "e1", "sum_e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.LONG });
RealMetadataFactory.createElements(vm1a2, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "e1", "sum_e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.LONG });
RealMetadataFactory.createElements(vm1a3, // $NON-NLS-1$
new String[] { "sum_e2" }, new String[] { DataTypeManager.DefaultDataTypes.LONG });
RealMetadataFactory.createElements(vm1a4, // $NON-NLS-1$
new String[] { "count" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
RealMetadataFactory.createElements(vm1a5, // $NON-NLS-1$
new String[] { "count" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
RealMetadataFactory.createElements(vm1a6, // $NON-NLS-1$
new String[] { "count" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
return RealMetadataFactory.createTransformationMetadata(metadataStore, "example1");
}
use of org.teiid.query.mapping.relational.QueryNode in project teiid by teiid.
the class TestLimit method exampleMetadata.
private static TransformationMetadata exampleMetadata() {
MetadataStore metadataStore = new MetadataStore();
// Create models
// $NON-NLS-1$
Schema pm1 = RealMetadataFactory.createPhysicalModel("pm1", metadataStore);
// $NON-NLS-1$
Schema vm1 = RealMetadataFactory.createVirtualModel("vm1", metadataStore);
// Create physical groups
// $NON-NLS-1$
Table pm1g1 = RealMetadataFactory.createPhysicalGroup("g1", pm1);
// $NON-NLS-1$
Table pm1g2 = RealMetadataFactory.createPhysicalGroup("g2", pm1);
// $NON-NLS-1$
Table pm1g3 = RealMetadataFactory.createPhysicalGroup("g3", pm1);
// $NON-NLS-1$
Table pm1g4 = RealMetadataFactory.createPhysicalGroup("g4", pm1);
// $NON-NLS-1$
Table pm1g5 = RealMetadataFactory.createPhysicalGroup("g5", pm1);
// $NON-NLS-1$
Table pm1g6 = RealMetadataFactory.createPhysicalGroup("g6", pm1);
// Create physical elements
RealMetadataFactory.createElements(pm1g1, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(pm1g2, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
RealMetadataFactory.createElements(pm1g3, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
List<Column> pm1g4e = RealMetadataFactory.createElements(pm1g4, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
pm1g4e.get(1).setSelectable(false);
pm1g4e.get(3).setSelectable(false);
List<Column> pm1g5e = RealMetadataFactory.createElements(pm1g5, // $NON-NLS-1$
new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
pm1g5e.get(0).setSelectable(false);
RealMetadataFactory.createElements(pm1g6, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "in", "in3" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
// Create virtual groups
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1g1n1 = new QueryNode("SELECT * FROM pm1.g1 LIMIT 100");
// $NON-NLS-1$
Table vm1g1 = RealMetadataFactory.createVirtualGroup("g1", vm1, vm1g1n1);
// Create virtual elements
RealMetadataFactory.createElements(vm1g1, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
// $NON-NLS-1$ //$NON-NLS-2$
QueryNode vm1g2n1 = new QueryNode("SELECT * FROM vm1.g1 ORDER BY e1");
// $NON-NLS-1$
Table vm1g2 = RealMetadataFactory.createVirtualGroup("g2", vm1, vm1g2n1);
// Create virtual elements
RealMetadataFactory.createElements(vm1g2, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { "e1", "e2", "e3", "e4" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
return RealMetadataFactory.createTransformationMetadata(metadataStore, "example");
}
use of org.teiid.query.mapping.relational.QueryNode 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);
}
Aggregations