Search in sources :

Example 51 with ValidatorReport

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

the class TestMetadataValidator method testResolveMetadata.

@Test
public void testResolveMetadata() throws Exception {
    String ddl = "create view g1 (e1 integer, e2 varchar(12)) AS select * from pm1.g1; " + "create view g2 AS select * from pm1.g1; " + "create trigger on g1 INSTEAD OF UPDATE AS FOR EACH ROW BEGIN ATOMIC END; " + "create virtual procedure proc1(IN e1 varchar) RETURNS (e1 integer, e2 varchar(12)) AS select * from foo; ";
    buildModel("pm1", true, this.vdb, this.store, "create foreign table g1(e1 integer, e2 varchar(12));");
    buildModel("vm1", false, this.vdb, this.store, ddl);
    buildTransformationMetadata();
    ValidatorReport report = new ValidatorReport();
    new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report, new MetadataValidator());
    assertTrue(printError(report), report.hasItems());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 52 with ValidatorReport

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

the class TestMetadataValidator method testExternalMaterializationValidate.

@Test
public void testExternalMaterializationValidate() throws Exception {
    String ddl = "CREATE FOREIGN TABLE G1(e1 integer, e2 varchar);" + "create foreign table status (VDBNAME STRING, VDBVERSION STRING, " + " SCHEMANAME STRING, NAME STRING, TARGETSCHEMANAME STRING, TARGETNAME STRING, " + " VALID BOOLEAN, LOADSTATE STRING, CARDINALITY LONG, UPDATED TIMESTAMP, LOADNUMBER LONG, NODENAME STRING, STALECOUNT LONG)";
    String ddl2 = "CREATE VIEW G2 OPTIONS (MATERIALIZED 'true', MATERIALIZED_TABLE 'pm1.G1', \"teiid_rel:MATVIEW_STATUS_TABLE\" 'pm1.status', \"teiid_rel:MATVIEW_LOAD_SCRIPT\" 'begin end') 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);
    assertFalse(printError(report), report.hasItems());
    assertNotNull("pm1.G1", store.getSchema("vm1").getTable("G2").getMaterializedTable());
    assertEquals("G1", store.getSchema("vm1").getTable("G2").getMaterializedTable().getName());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 53 with ValidatorReport

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

the class TestMetadataValidator method testExternalMaterializationValidateLoadScripts.

@Test
public void testExternalMaterializationValidateLoadScripts() 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\" 'status' , \"teiid_rel:MATVIEW_BEFORE_LOAD_SCRIPT\" '----') 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 54 with ValidatorReport

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

the class TestMetadataValidator method testExternalMaterializationValidateColumnTypes.

@Test
public void testExternalMaterializationValidateColumnTypes() throws Exception {
    String ddl = "CREATE FOREIGN TABLE G1(e1 integer, e2 integer);" + "create foreign table status (VDBNAME STRING, VDBVERSION STRING, " + " SCHEMANAME STRING, NAME STRING, TARGETSCHEMANAME STRING, TARGETNAME STRING, " + " VALID BOOLEAN, LOADSTATE STRING, CARDINALITY LONG, UPDATED TIMESTAMP, LOADNUMBER LONG, NODENAME STRING, STALECOUNT STRING)";
    String ddl2 = "CREATE VIEW G2 (e1 integer, e2 varchar) OPTIONS (MATERIALIZED 'true', MATERIALIZED_TABLE 'pm1.G1', \"teiid_rel:MATVIEW_STATUS_TABLE\" 'pm1.status', \"teiid_rel:MATVIEW_LOAD_SCRIPT\" 'begin end') AS SELECT 1, 'a' 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 55 with ValidatorReport

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

the class TestMetadataValidator method testViewModelArtifacts.

@Test
public void testViewModelArtifacts() throws Exception {
    String ddl = "create foreign table g1(e1 integer, e2 varchar(12)); create view g2(e1 integer, e2 varchar(12)) AS select * from foo;";
    buildModel("vm1", false, this.vdb, this.store, ddl);
    ValidatorReport report = new ValidatorReport();
    new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report, new MetadataValidator());
    assertTrue(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