我正在制作一个并行触发几个 REST POST 调用然后更新数据库中的表的管道。它将通过 ULTRA 任务使用。我正在使用脚本进行某些转换和映射,因为它们中的大多数都不是 ULTRA 兼容的(例如,tail 和 group by 字段),所以我无法使用传统的 snap 来执行这些转换和映射。
我知道我需要维护此类管道的沿袭信息才能完成 ULTRA 任务。请参阅以下文档。
每当我将结果写入输出时,我都会使用如下内容。
this.output.write(doc, wrapper);
但是文档中没有提到在发生错误时维护沿袭信息。我正在写的 catch 块中有一个类似的包装器,error
如下所示。
this.error.write(wrapper);
我从此脚本中收到以下错误。
Document created by 'Pre-DB Script[08755fd3-46b0-4f3a-b353-4a0685b649c4 -- 2b2bfab7-18f7-49ab-9a98-41bf0bc694eb]' does not contain lineage information and cannot be used as output from an Ultra pipeline
Resolution:
Use a Join snap to merge static documents into an Ultra input document or request that the snap be made Ultra-compatible
Reason:
The document was not created from an Ultra input document or was created by a Snap that is not Ultra-compatible
以下是相关的代码。
var impl = {
input: input,
output: output,
error: error,
log: log,
execute: function () {
// Some variables
var error = false;
this.log.info("Executing Transform Script");
while (this.input.hasNext()) {
try {
// Read the next document, wrap it in a map and write out the wrapper
var doc = this.input.next();
// Some operations
if (!doc.successful) {
error = true;
throw { message: doc.errors.errorDetailMessage, original: doc };
}
var wrapper = new java.util.HashMap();
// Add required fields to wrapper
wrapper.put("original", doc);
if (/* Should this wrapper be sent to output? */) {
if (!error) this.output.write(doc, wrapper);
error = false;
}
this.log.info("Transform Script finished");
}
catch (err) {
var wrapper = new java.util.HashMap();
wrapper.put("error", err.message);
wrapper.put("original", err.original);
this.log.error(err);
this.error.write(wrapper);
}
}
}
};
那么,在文档被路由到错误路径的情况下,如何解决沿袭信息问题?