use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method testResolveTempMetadata.
@Test
public void testResolveTempMetadata() throws Exception {
String ddl = "create virtual procedure proc1() RETURNS (e1 integer, e2 varchar(12)) AS begin create local temporary table x (e1 integer, e2 varchar); select * from x; end;" + "create view z (e1 integer, e2 varchar(12)) AS select x.* from (exec proc1()) as X, (exec proc1()) as Y; ";
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());
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method testFunctionProcedureValidation.
@Test
public void testFunctionProcedureValidation() throws Exception {
buildModel("phy1", true, this.vdb, this.store, "CREATE VIRTUAL FUNCTION f1(VARIADIC x integer) RETURNS integer as return (select e1 from g1 where e2 = array_length(x));; create foreign table g1 (e1 string, e2 integer);");
buildTransformationMetadata();
ValidatorReport report = new MetadataValidator().validate(this.vdb, this.store);
assertTrue(printError(report), report.hasItems());
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestSystemSource method testValidate.
@Test
public void testValidate() {
SystemSource source = new SystemSource();
// $NON-NLS-1$
ValidatorReport report = new ValidatorReport("Test Report");
FunctionMetadataValidator.validateFunctionMethods(source.getFunctionMethods(), report);
if (report.hasItems()) {
// $NON-NLS-1$
fail("Got validation errors while validating system functions: " + report);
}
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class RealMetadataFactory method fromDDL.
public static TransformationMetadata fromDDL(String vdbName, DDLHolder... schemas) throws Exception {
CompositeMetadataStore cms = new CompositeMetadataStore(Collections.EMPTY_LIST);
for (DDLHolder schema : schemas) {
MetadataFactory mf = TestDDLParser.helpParse(schema.ddl, schema.name);
cms.merge(mf.asMetadataStore());
}
TransformationMetadata tm = createTransformationMetadata(cms, vdbName);
ValidatorReport report = new MetadataValidator().validate(tm.getVdbMetaData(), tm.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
return tm;
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestExcelMetadataProcessor method getDDL.
static String getDDL(Properties props, String filename) throws TranslatorException, ResourceException {
ExcelExecutionFactory translator = new ExcelExecutionFactory();
translator.start();
String xlsName = props.getProperty("importer.excelFileName");
MetadataFactory mf = new MetadataFactory("vdb", 1, "people", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null);
FileConnection connection = Mockito.mock(FileConnection.class);
if (xlsName.contains("*.")) {
Mockito.stub(connection.getFile(xlsName)).toReturn(UnitTestUtil.getTestDataFile(xlsName));
File f = Mockito.mock(File.class);
Mockito.stub(f.isDirectory()).toReturn(true);
Mockito.stub(f.listFiles()).toReturn(new File[] { UnitTestUtil.getTestDataFile(filename) });
Mockito.stub(connection.getFile(xlsName)).toReturn(f);
} else {
Mockito.stub(connection.getFile(xlsName)).toReturn(UnitTestUtil.getTestDataFile(xlsName));
}
translator.getMetadata(mf, connection);
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "vdb", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
return ddl;
}
Aggregations