【发布时间】:2017-05-16 03:42:54
【问题描述】:
我正在尝试获取从云函数传递到数据流模板的属性值。我收到错误,因为传递的值是一个包装器,并且在编译期间使用 .get() 方法失败。有这个错误
An exception occurred while executing the Java class. null: InvocationTargetException: Not called from a runtime context.
public interface MyOptions extends DataflowPipelineOptions {
...
@Description("schema of csv file")
ValueProvider<String> getHeader();
void setHeader(ValueProvider<String> header);
...
}
public static void main(String[] args) throws IOException {
...
List<String> sideInputColumns = Arrays.asList(options.getHeader().get().split(","));
...
//ultimately use the getHeaders as side inputs
PCollection<String> input = p.apply(Create.of(sideInputColumns));
final PCollectionView<List<String>> finalColumnView = input.apply(View.asList());
}
如何从 ValueProvider 类型中提取值?
【问题讨论】:
-
请分享您的代码。
标签: google-cloud-dataflow google-cloud-functions google-api-nodejs-client