public ValidatorReport validate(VDBMetaData vdb, MetadataStore store) { ValidatorReport report = new ValidatorReport(); if (store != null && !store.getSchemaList().isEmpty()) { new SourceModelArtifacts().execute(vdb, store, report, this); new CrossSchemaResolver().execute(vdb, store, report, this); new ResolveQueryPlans().execute(vdb, store, report, this); new MinimalMetadata().execute(vdb, store, report, this); new MatViewPropertiesValidator().execute(vdb, store, report, this); } return report; }
public ValidatorReport validate(VDBMetaData vdb, MetadataStore store) { ValidatorReport report = new ValidatorReport(); if (store != null && !store.getSchemaList().isEmpty()) { new SourceModelArtifacts().execute(vdb, store, report, this); new CrossSchemaResolver().execute(vdb, store, report, this); new ResolveQueryPlans().execute(vdb, store, report, this); new MinimalMetadata().execute(vdb, store, report, this); new MatViewPropertiesValidator().execute(vdb, store, report, this); } return report; }
public ValidatorReport validate(VDBMetaData vdb, MetadataStore store) { ValidatorReport report = new ValidatorReport(); if (store != null && !store.getSchemaList().isEmpty()) { new SourceModelArtifacts().execute(vdb, store, report, this); new CrossSchemaResolver().execute(vdb, store, report, this); new ResolveQueryPlans().execute(vdb, store, report, this); new MinimalMetadata().execute(vdb, store, report, this); new MatViewPropertiesValidator().execute(vdb, store, report, this); } return report; }
@Test public void testProcMetadataValidationError() 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 not null); insert into x (e1) values (1); select * from x; end;"; buildModel("vm1", false, this.vdb, this.store, ddl); buildTransformationMetadata(); ValidatorReport report = new ValidatorReport(); new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report, new MetadataValidator()); assertEquals("TEIID31080 vm1.proc1 validation error: Element x.e2 of x is neither nullable nor has a default value. A value must be specified in the insert.", report.getItems().iterator().next().toString()); }
@Test public void testValidate() { SystemSource source = new SystemSource(); ValidatorReport report = new ValidatorReport("Test Report"); //$NON-NLS-1$ FunctionMetadataValidator.validateFunctionMethods(source.getFunctionMethods(), report); if(report.hasItems()) { fail("Got validation errors while validating system functions: " + report); //$NON-NLS-1$ } } }
@Test public void testSourceModelArtifacts() 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("pm1", true, this.vdb, this.store, ddl); ValidatorReport report = new ValidatorReport(); new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report, new MetadataValidator()); assertFalse(printError(report), report.hasItems()); }
@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()); }
@Test public void testEmptyKey() throws Exception { String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, PRIMARY KEY(g1e1, g1e2));"; buildModel("pm1", true, this.vdb, this.store, ddl); buildTransformationMetadata(); this.store.getSchema("pm1").getTable("G1").getPrimaryKey().getColumns().clear(); ValidatorReport report = new ValidatorReport(); report = new MetadataValidator().validate(this.vdb, this.store); assertTrue(printError(report), report.hasItems()); }
@Test public void testCrossReferenceFKNoPKonRefTable() throws Exception { // note here the unique here does not matter for non-existent reference columns, only primary key counted. String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, UNIQUE(g1e1, g1e2));"; String ddl2 = "CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, PRIMARY KEY(g2e1, g2e2), 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); assertTrue(printError(report), report.hasItems()); }
@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()); }
@Test public void testProcDependencies() throws Exception { String ddl = "create virtual procedure proc1(IN e1 varchar) as begin end; " + "create virtual procedure proc2(IN e1 varchar) RETURNS (x integer) as begin call proc1(e1); select 1; end; "; 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()); }
@Test public void testInvalidView() throws Exception { String ddl = "create view g1 (e1 integer, e2 varchar(12)) AS select 'a';"; 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()); }
@Test public void testModelArtifactsSucess() throws Exception { buildModel("vm1", false, this.vdb, this.store, "create view g2(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));"); ValidatorReport report = new ValidatorReport(); new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report, new MetadataValidator()); assertFalse(printError(report), report.hasItems()); }
@Test public void testExternalMaterializationValidateColumns() throws Exception { String ddl = "CREATE FOREIGN TABLE G1(e2 varchar);" + STATUS; 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()); }
@Test public void testExternalMaterializationValidateColumnTypes() throws Exception { String ddl = "CREATE FOREIGN TABLE G1(e1 integer, e2 integer);" + STATUS; 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()); }
@Test public void testResolveMetadataError() throws Exception { buildModel("vm1", false, this.vdb, this.store, "create view g1 (e1 integer, e2 varchar(12)) AS select * from pm1.g1; create view g2 AS select * from pm1.g1;"); buildTransformationMetadata(); ValidatorReport report = new ValidatorReport(); new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report, new MetadataValidator()); assertTrue(printError(report), report.hasItems()); }
@Test public void testInternalMaterializationValidate() throws Exception { // note here the unique here does not matter for non-existent reference columns, only primary key counted. String ddl = "CREATE FOREIGN TABLE G1(e1 integer, e2 varchar);"; String ddl2 = "CREATE VIEW G2 OPTIONS (MATERIALIZED 'YES') 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()); }
@Test public void testExternalMaterializationValidateMissingColumns() 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') 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()); }
@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()); }
private ValidatorReport helpTest(String ddl, boolean expectErrors) throws Exception { buildModel("pm1", true, this.vdb, this.store, ddl); buildTransformationMetadata(); ValidatorReport report = new ValidatorReport(); report = new MetadataValidator().validate(this.vdb, this.store); if (expectErrors) { assertTrue(printError(report), report.hasItems()); } else { assertFalse(printError(report), report.hasItems()); } return report; }