use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestProtobufMetadataProcessor method getTransformationMetadata.
public static TransformationMetadata getTransformationMetadata(MetadataFactory mf, InfinispanExecutionFactory ef) throws Exception {
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "proto", new FunctionTree("foo", new UDFSource(ef.getPushDownFunctions())));
ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
return metadata;
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestProcedurePlanner method helpPlanProcedure.
// ################ getReplacementClause tests ###################
private ProcessorPlan helpPlanProcedure(String userQuery, String procedure, TriggerEvent procedureType) throws TeiidComponentException, QueryMetadataException, TeiidProcessingException {
QueryMetadataInterface metadata = RealMetadataFactory.exampleUpdateProc(procedureType, procedure);
QueryParser parser = QueryParser.getQueryParser();
Command userCommand = userQuery != null ? parser.parseCommand(userQuery) : parser.parseCommand(procedure);
if (userCommand instanceof CreateProcedureCommand) {
GroupSymbol gs = new GroupSymbol("proc");
gs.setMetadataID(new TempMetadataID("proc", Collections.EMPTY_LIST));
((CreateProcedureCommand) userCommand).setVirtualGroup(gs);
}
QueryResolver.resolveCommand(userCommand, metadata);
ValidatorReport report = Validator.validate(userCommand, metadata);
if (report.hasItems()) {
ValidatorFailure firstFailure = report.getItems().iterator().next();
throw new QueryValidatorException(firstFailure.getMessage());
}
userCommand = QueryRewriter.rewrite(userCommand, metadata, null);
AnalysisRecord analysisRecord = new AnalysisRecord(false, DEBUG);
try {
return QueryOptimizer.optimizePlan(userCommand, metadata, null, new DefaultCapabilitiesFinder(), analysisRecord, null);
} finally {
if (DEBUG) {
System.out.println(analysisRecord.getDebugLog());
}
}
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestProcedureProcessor method getProcedurePlan.
public static ProcessorPlan getProcedurePlan(String userQuery, QueryMetadataInterface metadata, CapabilitiesFinder capabilitiesFinder) throws Exception {
Command userCommand = QueryParser.getQueryParser().parseCommand(userQuery);
QueryResolver.resolveCommand(userCommand, metadata);
ValidatorReport report = Validator.validate(userCommand, metadata);
if (report.hasItems()) {
ValidatorFailure firstFailure = report.getItems().iterator().next();
throw new QueryValidatorException(firstFailure.getMessage());
}
QueryRewriter.rewrite(userCommand, metadata, new CommandContext());
AnalysisRecord analysisRecord = new AnalysisRecord(false, DEBUG);
try {
if (capabilitiesFinder == null) {
capabilitiesFinder = new DefaultCapabilitiesFinder();
}
ProcessorPlan plan = QueryOptimizer.optimizePlan(userCommand, metadata, null, capabilitiesFinder, analysisRecord, null);
return plan;
} finally {
if (DEBUG) {
System.out.println(analysisRecord.getDebugLog());
}
}
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class FileUDFMetaData method buildFunctionModelFile.
public void buildFunctionModelFile(String name, String path) throws IOException, XMLStreamException {
for (String f : files.keySet()) {
if (f.endsWith(path)) {
path = f;
break;
}
}
VirtualFile file = this.files.get(path);
if (file == null) {
throw new IOException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40075, name));
}
List<FunctionMethod> udfMethods = FunctionMetadataReader.loadFunctionMethods(file.openStream());
// $NON-NLS-1$
ValidatorReport report = new ValidatorReport("UDF load");
FunctionMetadataValidator.validateFunctionMethods(udfMethods, report);
if (report.hasItems()) {
// $NON-NLS-1$
throw new IOException(QueryPlugin.Util.getString("ERR.015.001.0005", report));
}
this.methods.put(name, new UDFSource(udfMethods));
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class VDBRepository method finishDeployment.
public void finishDeployment(String name, String version) {
VDBKey key = new VDBKey(name, version);
CompositeVDB v = this.vdbRepo.get(key);
if (v == null) {
return;
}
VDBMetaData metadataAwareVDB = v.getVDB();
if (v.getOriginalVDB().getStatus() == Status.FAILED) {
if (v.getOriginalVDB() != metadataAwareVDB && metadataAwareVDB.getStatus() == Status.LOADING) {
metadataAwareVDB.setStatus(Status.FAILED);
}
return;
}
synchronized (metadataAwareVDB) {
try {
try {
v.metadataLoadFinished(allowEnv);
} catch (MetadataException e) {
// $NON-NLS-1$
LogManager.logWarning(LogConstants.CTX_RUNTIME, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version, e.getMessage()));
if (!metadataAwareVDB.isPreview()) {
ValidatorReport report = new ValidatorReport();
report.addItem(new ValidatorFailure(e.getMessage()));
if (!processMetadataValidatorReport(key, report)) {
metadataAwareVDB.setStatus(Status.FAILED);
notifyFinished(name, version, v);
return;
}
}
}
MetadataStore store = metadataAwareVDB.removeAttachment(MetadataStore.class);
ValidatorReport report = new MetadataValidator(store.getDatatypes(), QueryParser.getQueryParser()).validate(metadataAwareVDB, store);
if (report.hasItems()) {
LogManager.logWarning(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version, report.getItems().iterator().next()));
if (!metadataAwareVDB.isPreview() && !processMetadataValidatorReport(key, report)) {
metadataAwareVDB.setStatus(Status.FAILED);
notifyFinished(name, version, v);
return;
}
}
validateDataSources(metadataAwareVDB);
metadataAwareVDB.setStatus(Status.ACTIVE);
// for replication of events, temp tables and mat views
GlobalTableStore gts = CompositeGlobalTableStore.createInstance(v, this.bufferManager, this.objectReplictor);
metadataAwareVDB.addAttchment(GlobalTableStore.class, gts);
if (this.databaseStore != null) {
metadataAwareVDB.addAttchment(DatabaseStore.class, this.databaseStore);
}
notifyFinished(name, version, v);
} finally {
if (metadataAwareVDB.getStatus() != Status.ACTIVE && metadataAwareVDB.getStatus() != Status.FAILED) {
// guard against an unexpected exception - probably bad validation logic
metadataAwareVDB.setStatus(Status.FAILED);
notifyFinished(name, version, v);
}
}
}
}
Aggregations