Search in sources :

Example 1 with CompositeMetadataStore

use of org.teiid.query.metadata.CompositeMetadataStore in project teiid by teiid.

the class TestMetadataFactory method setUp.

@Before
public void setUp() {
    MetadataStore metadataStore = new MetadataStore();
    CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
    VDBMetaData vdbMetaData = new VDBMetaData();
    // $NON-NLS-1$
    vdbMetaData.setName("foo");
    vdbMetaData.setVersion(1);
    Map<String, VDBResources.Resource> vdbEntries = new LinkedHashMap<String, VDBResources.Resource>();
    vdbEntries.put(MY_RESOURCE_PATH, new VDBResources.Resource(root.getChild("foo")));
    metadataFactory = new RuntimeMetadataImpl(new TransformationMetadata(vdbMetaData, store, vdbEntries, null, null));
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) VDBResources(org.teiid.query.metadata.VDBResources) LinkedHashMap(java.util.LinkedHashMap) Before(org.junit.Before)

Example 2 with CompositeMetadataStore

use of org.teiid.query.metadata.CompositeMetadataStore in project teiid by teiid.

the class TestDependentJoins method testSystemDependent.

@Test
public void testSystemDependent() throws TeiidComponentException, TeiidProcessingException {
    // Create query
    // $NON-NLS-1$
    String sql = "SELECT pm1.g1.e1 FROM pm1.g1, sys.columns makedep where pm1.g1.e1 = sys.columns.name";
    CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(RealMetadataFactory.example1Store(), SystemMetadata.getInstance().getSystemStore()));
    TransformationMetadata tm = new TransformationMetadata(null, cms, null, null, null);
    BasicSourceCapabilities bsc = new BasicSourceCapabilities();
    bsc.setCapabilitySupport(Capability.CRITERIA_IN, true);
    ProcessorPlan plan = TestOptimizer.helpPlan(// $NON-NLS-1$
    sql, tm, null, new DefaultCapabilitiesFinder(bsc), new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT SYS.Columns.Name FROM SYS.Columns WHERE SYS.Columns.Name IN (<dependent values>)" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    1, // DependentAccess
    1, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    0, // NestedLoopJoinStrategy
    0, // MergeJoinStrategy
    1, // Null
    0, // PlanExecution
    0, // Project - we expect a project over the system query
    2, // Select
    0, // Sort
    0, // UnionAll
    0 });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 3 with CompositeMetadataStore

use of org.teiid.query.metadata.CompositeMetadataStore in project teiid by teiid.

the class QueryParser method parseDDL.

public void parseDDL(final MetadataFactory factory, Reader ddl) {
    SingleSchemaDatabaseStore store = new SingleSchemaDatabaseStore(factory);
    store.startEditing(true);
    Database db = new Database(factory.getVdbName(), factory.getVdbVersion());
    store.databaseCreated(db);
    store.databaseSwitched(factory.getVdbName(), factory.getVdbVersion());
    store.dataWrapperCreated(new DataWrapper(NONE));
    Server server = new Server(NONE);
    server.setDataWrapper(NONE);
    store.serverCreated(server);
    if (factory.getSchema().isPhysical()) {
        Server s = new Server(factory.getSchema().getName());
        s.setDataWrapper(NONE);
        store.serverCreated(s);
    }
    List<String> servers = Collections.emptyList();
    store.schemaCreated(factory.getSchema(), servers);
    // with the schema created, create the TransformationMetadata
    CompositeMetadataStore cms = new CompositeMetadataStore(db.getMetadataStore());
    TransformationMetadata qmi = new TransformationMetadata(DatabaseUtil.convert(db), cms, null, null, null);
    store.setTransformationMetadata(qmi);
    store.schemaSwitched(factory.getSchema().getName());
    store.setMode(Mode.SCHEMA);
    store.setStrict(true);
    try {
        parseDDL(store, ddl);
        Map<String, String> colNs = store.getNameSpaces();
        for (String key : colNs.keySet()) {
            factory.addNamespace(key, colNs.get(key));
        }
    } finally {
        store.stopEditing();
    }
}
Also used : DataWrapper(org.teiid.metadata.DataWrapper) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) Server(org.teiid.metadata.Server) Database(org.teiid.metadata.Database)

Example 4 with CompositeMetadataStore

use of org.teiid.query.metadata.CompositeMetadataStore in project teiid by teiid.

the class RealMetadataFactory method fromDDL.

public static TransformationMetadata fromDDL(String vdbName, DDLHolder... schemas) throws Exception {
    CompositeMetadataStore cms = new CompositeMetadataStore(Collections.EMPTY_LIST);
    for (DDLHolder schema : schemas) {
        MetadataFactory mf = TestDDLParser.helpParse(schema.ddl, schema.name);
        cms.merge(mf.asMetadataStore());
    }
    TransformationMetadata tm = createTransformationMetadata(cms, vdbName);
    ValidatorReport report = new MetadataValidator().validate(tm.getVdbMetaData(), tm.getMetadataStore());
    if (report.hasItems()) {
        throw new RuntimeException(report.getFailureMessage());
    }
    return tm;
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) MetadataValidator(org.teiid.query.metadata.MetadataValidator) ValidatorReport(org.teiid.query.validator.ValidatorReport)

Example 5 with CompositeMetadataStore

use of org.teiid.query.metadata.CompositeMetadataStore in project teiid by teiid.

the class TestSQLtoSpreadsheetQuery method dummySpreadsheetMetadata.

private QueryMetadataInterface dummySpreadsheetMetadata() throws Exception {
    GoogleSpreadsheetConnection conn = Mockito.mock(GoogleSpreadsheetConnection.class);
    Mockito.stub(conn.getSpreadsheetInfo()).toReturn(people);
    MetadataFactory factory = new MetadataFactory("", 1, "", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), "");
    GoogleMetadataProcessor processor = new GoogleMetadataProcessor();
    processor.process(factory, conn);
    return new TransformationMetadata(null, new CompositeMetadataStore(factory.asMetadataStore()), null, RealMetadataFactory.SFM.getSystemFunctions(), null);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Properties(java.util.Properties) GoogleSpreadsheetConnection(org.teiid.translator.google.api.GoogleSpreadsheetConnection)

Aggregations

CompositeMetadataStore (org.teiid.query.metadata.CompositeMetadataStore)13 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)13 MetadataStore (org.teiid.metadata.MetadataStore)5 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)4 Schema (org.teiid.metadata.Schema)4 ArrayList (java.util.ArrayList)3 MetadataFactory (org.teiid.metadata.MetadataFactory)3 FunctionTree (org.teiid.query.function.FunctionTree)3 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 Properties (java.util.Properties)2 Test (org.junit.Test)2 Column (org.teiid.metadata.Column)2 Table (org.teiid.metadata.Table)2 UDFSource (org.teiid.query.function.UDFSource)2 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)2 StringReader (java.io.StringReader)1 Clob (java.sql.Clob)1 SQLException (java.sql.SQLException)1 List (java.util.List)1