Search in sources :

Example 36 with MetadataStore

use of org.teiid.metadata.MetadataStore in project teiid by teiid.

the class TestModeShapeSqlTranslator method getMetadata.

public static TransformationMetadata getMetadata() {
    MetadataStore store = new MetadataStore();
    Schema modeshape = RealMetadataFactory.createPhysicalModel("modeshape", store);
    Table nt_base = RealMetadataFactory.createPhysicalGroup("nt_base", modeshape);
    nt_base.setNameInSource("\"nt:base\"");
    List<Column> cols = RealMetadataFactory.createElements(nt_base, new String[] { "jcr_path", "mode_properties", "jcr_primaryType", "prop" }, new String[] { TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.STRING });
    cols.get(0).setNameInSource("\"jcr:path\"");
    cols.get(1).setNameInSource("\"mode:properties\"");
    cols.get(2).setNameInSource("\"jcr:primaryType\"");
    Table nt_version = RealMetadataFactory.createPhysicalGroup("nt_version", modeshape);
    nt_version.setNameInSource("\"nt:version\"");
    List<Column> cols2 = RealMetadataFactory.createElements(nt_version, new String[] { "jcr_path", "mode_properties", "jcr_primaryType", "prop" }, new String[] { TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.STRING });
    cols2.get(0).setNameInSource("\"jcr:path\"");
    cols2.get(1).setNameInSource("\"mode:properties\"");
    cols2.get(2).setNameInSource("\"jcr:primaryType\"");
    return RealMetadataFactory.createTransformationMetadata(store, "modeshape");
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) Table(org.teiid.metadata.Table) Column(org.teiid.metadata.Column) Schema(org.teiid.metadata.Schema)

Example 37 with MetadataStore

use of org.teiid.metadata.MetadataStore in project teiid by teiid.

the class TestCoherenceTranslator method getTradeTranslationUtility.

/**
 * this is used as an alternative to loading the vdb
 * @return
 */
private TranslationUtility getTradeTranslationUtility() {
    MetadataStore metadataStore = new MetadataStore();
    // Create TRADE
    // $NON-NLS-1$
    Schema trading = RealMetadataFactory.createPhysicalModel("Trade_Object", metadataStore);
    // Create physical groups
    // $NON-NLS-1$
    Table trade = RealMetadataFactory.createPhysicalGroup("TRADE", trading);
    trade.setNameInSource("org.teiid.translator.coherence.Trade");
    // Create physical elements
    String[] elemNames = new String[] { // $NON-NLS-1$ //$NON-NLS-2$
    "NAME", // $NON-NLS-1$ //$NON-NLS-2$
    "TRADEID" };
    String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.LONG };
    List<Column> cols = RealMetadataFactory.createElements(trade, elemNames, elemTypes);
    // Set name in source on each column
    String[] nameInSource = new String[] { "Name", "TradeId" };
    for (int i = 0; i < nameInSource.length; i++) {
        cols.get(i).setNameInSource(nameInSource[i]);
    }
    List<Column> keys = new ArrayList(1);
    keys.add(cols.get(1));
    KeyRecord trade_pk = RealMetadataFactory.createKey(Type.Primary, "TradeID_PK", trade, keys);
    // LEG
    // $NON-NLS-1$
    Table leg = RealMetadataFactory.createPhysicalGroup("LEG", trading);
    leg.setNameInSource("org.teiid.translator.coherence.Leg");
    // Create physical elements
    String[] legNames = new String[] { // $NON-NLS-1$ //$NON-NLS-2$
    "LEGID", // $NON-NLS-1$ //$NON-NLS-2$
    "NOTATIONAL", // $NON-NLS-1$ //$NON-NLS-2$
    "NAME", // $NON-NLS-1$ //$NON-NLS-2$
    "TRADEID" };
    String[] legTypes = new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.LONG };
    List<Column> legcols = RealMetadataFactory.createElements(leg, legNames, legTypes);
    // Set name in source on each column
    String[] legnameInSource = new String[] { "LegId", "Notational", "Name", "TradeId" };
    for (int i = 0; i < legnameInSource.length; i++) {
        legcols.get(i).setNameInSource(legnameInSource[i]);
    }
    legcols.get(3).setSelectable(false);
    legcols.get(3).setUpdatable(false);
    List<Column> legkeys = new ArrayList(1);
    keys.add(legcols.get(0));
    RealMetadataFactory.createKey(Type.Primary, "Leg_ID_PK", leg, legkeys);
    List<Column> foreignkey = new ArrayList(1);
    foreignkey.add(legcols.get(3));
    ForeignKey fk = RealMetadataFactory.createForeignKey("TRADE_FK", leg, foreignkey, trade_pk);
    fk.setNameInSource("Legs");
    fk.setParent(trade);
    // Set column-specific properties
    // cols.get(0).setSelectable(false);
    // cols.get(0).setSearchType(SearchType.Unsearchable);
    Schema tradeview = RealMetadataFactory.createVirtualModel("Trade_View", metadataStore);
    QueryNode qn = new QueryNode("SELECT Trade_Object.Trade.TradeID, Trade_Object.Trade.Name, Trade_Object.Leg.LegID, Trade_Object.Leg.Notational, Trade_Object.Leg.Name AS LegName " + " FROM Trade_Object.Trade, Trade_Object.Leg " + "WHERE	Trade_Object.Trade.TradeID = Trade_Object.Leg.TradeID " + "SELECT * FROM Trade.Trad " + " WHERE Trade.Trade.TradeID = Trade.Trade.TradeID");
    Table trades = RealMetadataFactory.createVirtualGroup("Trades", tradeview, qn);
    return new TranslationUtility(RealMetadataFactory.createTransformationMetadata(metadataStore, "Trade"));
}
Also used : Table(org.teiid.metadata.Table) Schema(org.teiid.metadata.Schema) ArrayList(java.util.ArrayList) TranslationUtility(org.teiid.cdk.api.TranslationUtility) ForeignKey(org.teiid.metadata.ForeignKey) MetadataStore(org.teiid.metadata.MetadataStore) KeyRecord(org.teiid.metadata.KeyRecord) Column(org.teiid.metadata.Column) QueryNode(org.teiid.query.mapping.relational.QueryNode)

Example 38 with MetadataStore

use of org.teiid.metadata.MetadataStore in project teiid by teiid.

the class EvaluatorIterator method createTransformationMetadata.

public static TransformationMetadata createTransformationMetadata(String ddl) {
    MetadataStore mds = new MetadataStore();
    MetadataFactory mf = new MetadataFactory("vdb", 1, IMPLICIT_MODEL_NAME, SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    QueryParser.getQueryParser().parseDDL(mf, ddl);
    mf.mergeInto(mds);
    CompositeMetadataStore store = new CompositeMetadataStore(mds);
    VDBMetaData vdbMetaData = new VDBMetaData();
    // $NON-NLS-1$
    vdbMetaData.setName("vdb");
    vdbMetaData.setVersion(1);
    List<FunctionTree> udfs = new ArrayList<FunctionTree>();
    for (Schema schema : store.getSchemas().values()) {
        vdbMetaData.addModel(createModel(schema.getName(), schema.isPhysical()));
    }
    TransformationMetadata metadata = new TransformationMetadata(vdbMetaData, store, null, SFM.getSystemFunctions(), udfs);
    vdbMetaData.addAttchment(TransformationMetadata.class, metadata);
    vdbMetaData.addAttchment(QueryMetadataInterface.class, metadata);
    return metadata;
}
Also used : CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) FunctionTree(org.teiid.query.function.FunctionTree) MetadataFactory(org.teiid.metadata.MetadataFactory) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Schema(org.teiid.metadata.Schema) ArrayList(java.util.ArrayList) Properties(java.util.Properties)

Example 39 with MetadataStore

use of org.teiid.metadata.MetadataStore 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");
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) Table(org.teiid.metadata.Table) Column(org.teiid.metadata.Column) QueryNode(org.teiid.query.mapping.relational.QueryNode) Schema(org.teiid.metadata.Schema)

Example 40 with MetadataStore

use of org.teiid.metadata.MetadataStore 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");
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) Table(org.teiid.metadata.Table) QueryNode(org.teiid.query.mapping.relational.QueryNode) Schema(org.teiid.metadata.Schema)

Aggregations

MetadataStore (org.teiid.metadata.MetadataStore)73 Schema (org.teiid.metadata.Schema)47 Test (org.junit.Test)38 Table (org.teiid.metadata.Table)37 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)22 QueryNode (org.teiid.query.mapping.relational.QueryNode)19 Column (org.teiid.metadata.Column)17 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)15 Properties (java.util.Properties)12 MetadataFactory (org.teiid.metadata.MetadataFactory)12 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)12 Procedure (org.teiid.metadata.Procedure)11 List (java.util.List)9 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)9 Connection (java.sql.Connection)8 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)8 ArrayList (java.util.ArrayList)7 ProcedureParameter (org.teiid.metadata.ProcedureParameter)7 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)7 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)6