@Test public void testCreateTempTable3() throws QueryParserException { String sql = "Create TEMPORARY table tempTable (c1 boolean, c2 byte)"; assertEquals( "CREATE LOCAL TEMPORARY TABLE tempTable (c1 boolean, c2 byte)", QueryParser.getQueryParser().parseCommand(sql).toString()); // $NON-NLS-1$ }
@Test public void testViewWithoutColumns() throws Exception { MetadataStore mds = new MetadataStore(); MetadataFactory mf = new MetadataFactory(null, 1, "VM1", getDataTypes(), new Properties(), null); parser.parseDDL(mf, "CREATE VIEW V1 AS SELECT * FROM PM1.G1"); mf.mergeInto(mds); }
@Test(expected = MetadataException.class) public void testTableWithPlan() throws Exception { String ddl = "CREATE foreign table G1 as select 1"; MetadataStore mds = new MetadataStore(); MetadataFactory mf = new MetadataFactory(null, 1, "model", getDataTypes(), new Properties(), null); parser.parseDDL(mf, ddl); mf.mergeInto(mds); }
@Test public void testAutoIncrementPrimarykey() throws Exception { String ddl = "CREATE FOREIGN TABLE G1( e1 integer auto_increment primary key, e2 varchar)"; MetadataStore mds = new MetadataStore(); MetadataFactory mf = new MetadataFactory(null, 1, "model", getDataTypes(), new Properties(), null); parser.parseDDL(mf, ddl); mf.mergeInto(mds); }
@Test(expected = MetadataException.class) public void testDuplicatePrimarykey() throws Exception { String ddl = "CREATE FOREIGN TABLE G1( e1 integer primary key, e2 varchar primary key)"; MetadataStore mds = new MetadataStore(); MetadataFactory mf = new MetadataFactory(null, 1, "model", getDataTypes(), new Properties(), null); parser.parseDDL(mf, ddl); mf.mergeInto(mds); }
@Test public void testReservedURIDifferentNS() throws Exception { String ddl = "set namespace 'http://www.teiid.org/translator/salesforce/2012' AS ns"; MetadataStore mds = new MetadataStore(); MetadataFactory mf = new MetadataFactory(null, 1, "model", getDataTypes(), new Properties(), null); parser.parseDDL(mf, ddl); mf.mergeInto(mds); assertTrue(mf.getNamespaces().keySet().contains("ns")); assertEquals("http://www.teiid.org/translator/salesforce/2012", mf.getNamespaces().get("ns")); }
@Test(expected = MetadataException.class) public void testReservedNamespacePrefixMismatch() throws Exception { String ddl = "set namespace 'http://www.teiid.org/translator/salesforce/2012' AS teiid_foo"; MetadataStore mds = new MetadataStore(); MetadataFactory mf = new MetadataFactory(null, 1, "model", getDataTypes(), new Properties(), null); parser.parseDDL(mf, ddl); mf.mergeInto(mds); assertTrue(mf.getNamespaces().keySet().contains("teiid_foo")); assertEquals( "http://www.teiid.org/translator/salesforce/2012", mf.getNamespaces().get("teiid_foo")); }
@Test public void testNamespace() throws Exception { String ddl = "set namespace 'http://teiid.org' AS teiid"; MetadataStore mds = new MetadataStore(); MetadataFactory mf = new MetadataFactory(null, 1, "model", getDataTypes(), new Properties(), null); parser.parseDDL(mf, ddl); mf.mergeInto(mds); assertTrue(mf.getNamespaces().keySet().contains("teiid")); assertEquals("http://teiid.org", mf.getNamespaces().get("teiid")); }
public static MetadataFactory helpParse(String ddl, String model) { MetadataFactory mf = new MetadataFactory(null, 1, model, getDataTypes(), new Properties(), null); QueryParser.getQueryParser().parseDDL(mf, ddl); return mf; }