Search in sources :

Example 56 with ValidatorReport

use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.

the class TestMetadataValidator method testProcMetadata.

@Test
public void testProcMetadata() throws Exception {
    String ddl = "create virtual procedure proc1(IN e1 varchar) RETURNS (e1 integer, e2 varchar(12)) AS begin create local temporary table x (e1 integer, e2 varchar); select * from x; end;" + "create virtual procedure proc2(IN e1 varchar) RETURNS (e1 integer, e2 varchar(12)) AS select x.* from (exec proc1('a')) as X; ";
    buildModel("vm1", false, this.vdb, this.store, ddl);
    buildTransformationMetadata();
    ValidatorReport report = new ValidatorReport();
    new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report, new MetadataValidator());
    assertFalse(printError(report), report.hasItems());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 57 with ValidatorReport

use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.

the class TestMetadataValidator method testExternalMaterializationValidateMissingStatus.

@Test
public void testExternalMaterializationValidateMissingStatus() throws Exception {
    String ddl = "CREATE FOREIGN TABLE G1(e1 integer, e2 varchar); CREATE FOREIGN TABLE status(e1 integer, e2 varchar);";
    String ddl2 = "CREATE VIEW G2 OPTIONS (MATERIALIZED 'true', MATERIALIZED_TABLE 'pm1.G1', \"teiid_rel:MATVIEW_STATUS_TABLE\" 'x') AS SELECT * FROM pm1.G1";
    buildModel("pm1", true, this.vdb, this.store, ddl);
    buildModel("vm1", false, this.vdb, this.store, ddl2);
    buildTransformationMetadata();
    ValidatorReport report = new ValidatorReport();
    report = new MetadataValidator().validate(this.vdb, this.store);
    assertTrue(printError(report), report.hasItems());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 58 with ValidatorReport

use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.

the class TestMetadataValidator method testViewKeys.

@Test
public void testViewKeys() throws Exception {
    buildModel("phy1", true, this.vdb, this.store, "CREATE FOREIGN TABLE t1 ( col1 string, col2 integer ) options (updatable true)");
    buildModel("phy2", true, this.vdb, this.store, "CREATE FOREIGN TABLE t2 ( col1 string, col2 integer ) options (updatable true)");
    buildModel("view1", false, this.vdb, this.store, "CREATE view vw_t1 ( col1 string, col2 integer primary key, foreign key (col2) references vw_t2 (col2) ) options (updatable true) as select * from t1;" + "CREATE view vw_t2 ( col1 string, col2 integer primary key, foreign key (col2) references vw_t1 (col2) ) options (updatable true) as select * from t2;" + "CREATE VIEW v1 ( col1 string, col2 integer ) OPTIONS (updatable 'true') AS select vw_t1.col1, vw_t1.col2 FROM vw_t1, vw_t2 where vw_t1.col2 = vw_t2.col2");
    buildTransformationMetadata();
    ValidatorReport report = new MetadataValidator().validate(this.vdb, this.store);
    assertFalse(printError(report), report.hasItems());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 59 with ValidatorReport

use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.

the class TestMetadataValidator method testCrossReferenceResoveOptionalFK.

@Test
public void testCrossReferenceResoveOptionalFK() throws Exception {
    String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, PRIMARY KEY(g1e1, g1e2));";
    String ddl2 = "CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, FOREIGN KEY (g2e1, g2e2) REFERENCES pm1.G1)";
    buildModel("pm1", true, this.vdb, this.store, ddl);
    buildModel("pm2", true, this.vdb, this.store, ddl2);
    buildTransformationMetadata();
    ValidatorReport report = new ValidatorReport();
    report = new MetadataValidator().validate(this.vdb, this.store);
    assertFalse(printError(report), report.hasItems());
    assertNotNull(this.store.getSchema("pm2").getTable("G2").getForeignKeys().get(0).getReferenceKey());
    assertEquals(2, this.store.getSchema("pm2").getTable("G2").getForeignKeys().get(0).getReferenceKey().getColumns().size());
    assertEquals("g1e1", this.store.getSchema("pm2").getTable("G2").getForeignKeys().get(0).getReferenceKey().getColumns().get(0).getName());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 60 with ValidatorReport

use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.

the class TestMetadataValidator method testResolvingOrder.

@Test
public void testResolvingOrder() throws Exception {
    buildModel("phy1", true, this.vdb, this.store, "CREATE FOREIGN TABLE t1 ( col1 string, col2 integer ) options (updatable true); CREATE view a as select * from t1;");
    buildTransformationMetadata();
    ValidatorReport report = new MetadataValidator().validate(this.vdb, this.store);
    assertFalse(printError(report), report.hasItems());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Aggregations

ValidatorReport (org.teiid.query.validator.ValidatorReport)70 Test (org.junit.Test)40 MetadataValidator (org.teiid.query.metadata.MetadataValidator)20 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)16 MetadataFactory (org.teiid.metadata.MetadataFactory)13 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)12 UDFSource (org.teiid.query.function.UDFSource)11 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)10 FunctionTree (org.teiid.query.function.FunctionTree)10 Command (org.teiid.query.sql.lang.Command)8 ValidatorFailure (org.teiid.query.validator.ValidatorFailure)6 QueryParser (org.teiid.query.parser.QueryParser)5 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)5 FileReader (java.io.FileReader)4 Properties (java.util.Properties)4 EdmxFormatParser (org.odata4j.format.xml.EdmxFormatParser)4 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)4 TranslationUtility (org.teiid.cdk.api.TranslationUtility)4 MetadataException (org.teiid.metadata.MetadataException)4 Table (org.teiid.metadata.Table)4