我们编写了一个 Google 数据流代码,该代码将一个值插入到一个列是 DateTime 类型的 bigquery 表中。大多数时候逻辑运行良好。但是突然我们遇到了无效的日期时间问题。
Exception: java.lang.RuntimeException: java.io.IOException: Insert failed: [{"errors":[{"debugInfo":"generic::out_of_range: Invalid datetime string \"2017-09-26T21:16\"
Run Code Online (Sandbox Code Playgroud)
目前尚不清楚上述值如何以及为何无效。我们看到它遵循https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types 中提到的 DateTime 数据类型
此外,目前还不清楚为什么它只是偶尔抛出这个错误。
我们写了一个自定义的转换代码来扩展 DoFn ProcessElement 代码是这样的
public void processElement(ProcessContext c) throws Exception {
TableRow tableRow = c.element();
try {
// do some processing then
tableRow.set("PredictedDate",**LocalDateTime.now().toString()**);
c.output(tableRow);
}catch(Exception exc){
LOG.error("Exception while processing and hence not attempting to write to bigquery");
}
}
enter code here
Run Code Online (Sandbox Code Playgroud)
它工作正常,但在夜间(美国中部时区)偶尔会失败。你能帮我们找到根本原因吗?