@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); }
private TransformationMetadata partitionedStartSchema() throws Exception, TeiidComponentException, QueryMetadataException { TransformationMetadata tm = RealMetadataFactory.fromDDL("x", new RealMetadataFactory.DDLHolder("source1", "create foreign table fact (id integer, dim_id1 integer, dim_id2 integer);" + "create foreign table dim1 (id integer, val string);" + "create foreign table dim2 (id integer, val string);"), new RealMetadataFactory.DDLHolder("source2", "create foreign table fact (id integer, dim_id1 integer, dim_id2 integer);" + "create foreign table dim1 (id integer, val string);" + "create foreign table dim2 (id integer, val string);"), new RealMetadataFactory.DDLHolder("v", "create view combined_fact as select id, dim_id1, dim_id2, 1 as part from source1.fact union all select id, dim_id1, dim_id2, 2 as part from source2.fact;" + "create view combined_dim1 as select id, val, 1 as part from source1.dim1 union all select id, val, 2 as part from source2.dim1;" + "create view combined_dim2 as select id, val, 1 as part from source1.dim2 union all select id, val, 2 as part from source2.dim2;") ); tm.getModelID("v").setProperty("implicit_partition.columnName", "part"); return tm; }
return getCurrentDatabase(); case SCHEMA: Schema schema = qmi.getModelID(name); if (schema == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31234,
return getCurrentDatabase(); case SCHEMA: Schema schema = qmi.getModelID(name); if (schema == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31234,
return getCurrentDatabase(); case SCHEMA: Schema schema = qmi.getModelID(name); if (schema == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31234,