简体   繁体   English

数据流-动态创建配置 Apache Beam

[英]Dataflow- dynamic create disposition Apache Beam

I want to dynamically choose from Create Disposition options depending on the arguments.我想根据 arguments 从创建处置选项中动态选择。 In the the DataflowPipelineOptions I am accepting load type in a ValueProvider via arguments.在 DataflowPipelineOptions 中,我通过 arguments 接受 ValueProvider 中的负载类型。 However I am not able to get the string from the ValueProvider to decide on what create disposition option to use.但是,我无法从 ValueProvider 获取字符串来决定使用什么创建处置选项。

withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED)

I want 'CREATE_IF_NEEDED' to be dynamic.我希望“CREATE_IF_NEEDED”是动态的。 I want to replace this with something like this.我想用这样的东西代替它。 Note following is just a pseudocode.注意以下只是一个伪代码。 I am looking for solution here.我在这里寻找解决方案。

create_disp = options.getLoad()
withCreateDisposition(create_disp 

You can pass a program argument representing createDisposition您可以传递代表createDisposition的程序参数

Program argument (CREATE_NEVER or CREATE_IF_NEEDED):程序参数(CREATE_NEVER 或 CREATE_IF_NEEDED):

--bqCreateDisposition=CREATE_NEVER

In the Option class in Java , you can pass a field as Enum (there is a default value in this case with CREATE_IF_NEEDED):在 Java 的选项Java中,您可以将字段作为 Enum 传递(在这种情况下,有一个默认值是 CREATE_IF_NEEDED):

public interface MyOptions extends PipelineOptions {

    @Description("BQ create disposition")
    @Default
    @Enum("CREATE_IF_NEEDED")
    BigQueryIO.Write.CreateDisposition getBqCreateDisposition();

    void setBqCreateDisposition(BigQueryIO.Write.CreateDisposition value);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM