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));
}
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 });
}
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();
}
}
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;
}
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);
}
Aggregations