简体   繁体   中英

Dataflow- dynamic create disposition Apache Beam

I want to dynamically choose from Create Disposition options depending on the arguments. In the the DataflowPipelineOptions I am accepting load type in a ValueProvider via arguments. However I am not able to get the string from the ValueProvider to decide on what create disposition option to use.

withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED)

I want 'CREATE_IF_NEEDED' to be dynamic. 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

Program argument (CREATE_NEVER or 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):

public interface MyOptions extends PipelineOptions {

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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