@Override public Schema getModelID(String modelName) throws TeiidComponentException, QueryMetadataException { Schema s = this.getMetadataStore().getSchema(modelName); if (s == null) { throw new QueryMetadataException(QueryPlugin.Event.TEIID30352, modelName+TransformationMetadata.NOT_EXISTS_MESSAGE); } return s; }
@Override public TransformationMetadata getDesignTimeMetadata() { TransformationMetadata tm = new TransformationMetadata(store, functionLibrary); tm.groupInfoCache = this.groupInfoCache; tm.metadataCache = this.metadataCache; tm.partialNameToFullNameCache = this.partialNameToFullNameCache; tm.procedureCache = this.procedureCache; tm.scriptEngineManager = this.scriptEngineManager; tm.importedModels = this.importedModels; tm.allowedLanguages = this.allowedLanguages; tm.widenComparisonToString = this.widenComparisonToString; return tm; }
id = globalStore.getGlobalTempTableMetadataId(tm.getGroupID(viewFullName)); Schema s = tm.getMetadataStore().getSchema(key.get(0)); Modifiable m = s.getTables().get(key.get(1)); if (m == null) {
TransformationMetadata metadata = new TransformationMetadata(vdb, compositeStore, visibilityMap, systemFunctions, udfs); metadata.setAllowENV(allowEnv); metadata.setLongRanks(AggregateSymbol.LONG_RANKS); metadata.setUseOutputNames(false); metadata.setWidenComparisonToString(WIDEN_COMPARISON_TO_STRING); return metadata;
@Test public void testUniqueReferencedKey() throws Exception { TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/keys.vdb"); Collection fks = tm.getForeignKeysInGroup(tm.getGroupID("x.a")); assertEquals(1, fks.size()); Object pk = tm.getPrimaryKeyIDForForeignKeyID(fks.iterator().next()); assertNotNull(pk); }
final VDBMetaData vdb = workContext.getVDB(); TransformationMetadata indexMetadata = vdb.getAttachment(TransformationMetadata.class); CompositeMetadataStore metadata = indexMetadata.getMetadataStore(); if (command instanceof Query) { Query query = (Query)command; indexMetadata.addToMetadataCache(target, "transformation/matview", null); //$NON-NLS-1$ if (proc.returnParameters()) { if (result == null) { final Table table = indexMetadata.getGroupID((String)((Constant)proc.getParameter(1).getExpression()).getValue()); switch (sysProc) { case SETCOLUMNSTATS:
@Test public void testCompareCriteriaSearchableFail() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Object modelID = metadata.getMetadataStore().getSchema("PM1"); Column e1 = metadata.getElementID("pm1.g1.e1"); e1.setSearchType(SearchType.Like_Only); FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = new BasicSourceCapabilities(); caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ helpTestVisitor("pm1.g1.e1 = 'x'", modelID, metadata, capFinder, false, false); }
Collection<Procedure> procRecords = getMetadataStore().getStoredProcedure(canonicalName); if (procRecords.isEmpty()) { return null; int direction = this.convertParamRecordTypeToStoredProcedureType(paramRecord.getType());
final VDBMetaData vdb = workContext.getVDB(); TransformationMetadata indexMetadata = vdb.getAttachment(TransformationMetadata.class); CompositeMetadataStore metadata = indexMetadata.getMetadataStore(); if (command instanceof Query) { Query query = (Query)command; indexMetadata.addToMetadataCache(target, "transformation/matview", null); //$NON-NLS-1$ if (proc.returnParameters()) { if (result == null) { final Table table = indexMetadata.getGroupID((String)((Constant)proc.getParameter(1).getExpression()).getValue()); switch (sysProc) { case SETCOLUMNSTATS: case GETXMLSCHEMAS: try { Object groupID = indexMetadata.getGroupID((String)((Constant)proc.getParameter(1).getExpression()).getValue()); List<SQLXMLImpl> schemas = indexMetadata.getXMLSchemas(groupID); for (SQLXMLImpl schema : schemas) { rows.add(Arrays.asList(new XMLType(schema)));
StoredProcedureInfo sp = qmi.getStoredProcedureInfoForProcedure(name); if (sp == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31213, Column c = qmi.getElementID(name); if (c == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31223, return getCurrentDatabase(); case SCHEMA: Schema schema = qmi.getModelID(name); if (schema == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31234,
return (Table)gs.getMetadataID(); case PROCEDURE: StoredProcedureInfo sp = qmi.getStoredProcedureInfoForProcedure(name); return (Procedure)sp.getProcedureID(); case DATABASE: return getCurrentDatabase(); case SCHEMA: Schema schema = qmi.getModelID(name); if (schema == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31234,
vdb.addModel(model2); TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, RealMetadataFactory.SFM.getSystemFunctions(), null); Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$ assertEquals(2, result.size()); tm = new TransformationMetadata(vdb, cms, null, RealMetadataFactory.SFM.getSystemFunctions(), null); result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$ assertEquals(1, result.size());
@Test public void testMultiple() throws Exception { TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/ZZZ.vdb"); Collection<String> names = tm.getGroupsForPartialName("PRODUCTDATA"); assertEquals(1, names.size()); names = tm.getGroupsForPartialName("PARTS"); assertEquals(1, names.size()); //ensure that datatypes are set Table t = tm.getGroupID(names.iterator().next()); assertNotNull(t.getColumns().get(0).getDatatype()); }
@BeforeClass public static void oneTimeSetup() throws Exception { tm = RealMetadataFactory.example1(); Table t = tm.getGroupID("pm1.g1"); t.setProperty(RulePlaceAccess.CONFORMED_SOURCES, "pm2"); t = tm.getGroupID("pm2.g3"); t.setProperty(RulePlaceAccess.CONFORMED_SOURCES, "pm1"); t = tm.getGroupID("pm2.g1"); t.setProperty(RulePlaceAccess.CONFORMED_SOURCES, "pm3"); }
public static String setProperty(final VDBMetaData vdb, final AbstractMetadataRecord record, final String key, final String value) { TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class); String result = record.setProperty(key, value); metadata.addToMetadataCache(record, "transformation/matview", null); //$NON-NLS-1$ if (record instanceof Table) { ((Table)record).setLastModified(System.currentTimeMillis()); } else if (record instanceof Procedure) { ((Procedure)record).setLastModified(System.currentTimeMillis()); } return result; }
fakeMetadata.getGroupID("pm1.g1").getAccessPatterns().clear(); RealMetadataFactory.setCardinality("pm1.g1", 1000, fakeMetadata); fakeMetadata.getElementID("pm1.g1.e1").setDistinctValues(40); RealMetadataFactory.setCardinality("pm3.g1", 1, fakeMetadata); fakeMetadata.getElementID("pm3.g1.e1").setDistinctValues(1);
@Test public void testIndex() throws Exception { TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/ora.vdb"); Collection indexes = tm.getIndexesInGroup(tm.getGroupID("ORACLE_BQT.SMALLA")); assertEquals(1, indexes.size()); }
@Test public void testProcVisibility() throws Exception { TransformationMetadata tm = exampleTransformationMetadata(); VDBMetaData vdb = tm.getVdbMetaData(); vdb.getModel("x").setVisible(false); StoredProcedureInfo spi = tm.getStoredProcedureInfoForProcedure("y"); //$NON-NLS-1$ assertEquals("x1.y", spi.getProcedureCallableName()); spi = tm.getStoredProcedureInfoForProcedure("x.y"); //$NON-NLS-1$ assertEquals("x.y", spi.getProcedureCallableName()); }
@Test public void testFK() throws Exception { String ddl = "CREATE FOREIGN TABLE G1(\"g1-e1\" integer, g1e2 varchar, PRIMARY KEY(\"g1-e1\", g1e2));\n" + "CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, " + "FOREIGN KEY (g2e1, g2e2) REFERENCES G1 (\"g1-e1\", g1e2))"; String expected = "CREATE FOREIGN TABLE G1 (\n" + " \"g1-e1\" integer,\n" + " g1e2 string,\n" + " PRIMARY KEY(\"g1-e1\", g1e2)\n" + ");\n" + "\n" + "CREATE FOREIGN TABLE G2 (\n" + " g2e1 integer,\n" + " g2e2 string,\n" + " FOREIGN KEY(g2e1, g2e2) REFERENCES G1 (\"g1-e1\", g1e2)\n" + ");"; TransformationMetadata vdb = RealMetadataFactory.fromDDL(ddl, "x", "y"); Schema s = vdb.getModelID("y"); String metadataDDL = DDLStringVisitor.getDDLString(s, null, null); assertEquals(expected, metadataDDL); }
public MappingNode getMappingNode(final Object groupID) throws TeiidComponentException, QueryMetadataException { Table tableRecord = (Table) groupID; MappingDocument mappingDoc = (MappingDocument) getFromMetadataCache(groupID, "xml-doc"); //$NON-NLS-1$ if (mappingDoc != null) { return mappingDoc; } final String groupName = tableRecord.getFullName(); if(tableRecord.isVirtual()) { // get mapping transform String document = tableRecord.getSelectTransformation(); InputStream inputStream = new ByteArrayInputStream(document.getBytes()); MappingLoader reader = new MappingLoader(); try{ mappingDoc = reader.loadDocument(inputStream); mappingDoc.setName(groupName); } catch (Exception e){ throw new TeiidComponentException(QueryPlugin.Event.TEIID30363, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30363, groupName, mappingDoc)); } finally { try { inputStream.close(); } catch(Exception e) {} } addToMetadataCache(groupID, "xml-doc", mappingDoc); //$NON-NLS-1$ return mappingDoc; } return null; }