Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] [BEAM-7590] Converting JDBC Pipeline Options Map to PipelineOptions. #8928

Closed
wants to merge 1 commit into from

Conversation

riazela
Copy link
Contributor

@riazela riazela commented Jun 21, 2019

There were two representation of pipeline options in JDBC Driver. This will combine them and we will keep only PipelineOptions Class.
This will slightly change the JDBC set command. Previously if we had set an incorrect option it would ignore it until the execution of an actual query; whereas now, it will throw exception if you try to set an incorrect pipeline option.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- Build Status --- --- Build Status
Java Build Status Build Status Build Status Build Status
Build Status
Build Status
Build Status Build Status Build Status
Build Status
Python Build Status
Build Status
--- Build Status
Build Status
Build Status --- --- Build Status

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website
Non-portable Build Status Build Status Build Status Build Status
Portable --- Build Status --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

@riazela riazela force-pushed the pipeline_option branch 4 times, most recently from 3e7a315 to 302efad Compare June 24, 2019 18:54
@riazela
Copy link
Contributor Author

riazela commented Jun 24, 2019

Run Java_Examples_Dataflow PreCommit

5 similar comments
@riazela
Copy link
Contributor Author

riazela commented Jun 24, 2019

Run Java_Examples_Dataflow PreCommit

@riazela
Copy link
Contributor Author

riazela commented Jun 24, 2019

Run Java_Examples_Dataflow PreCommit

@riazela
Copy link
Contributor Author

riazela commented Jun 24, 2019

Run Java_Examples_Dataflow PreCommit

@riazela
Copy link
Contributor Author

riazela commented Jun 24, 2019

Run Java_Examples_Dataflow PreCommit

@riazela
Copy link
Contributor Author

riazela commented Jun 24, 2019

Run Java_Examples_Dataflow PreCommit

@SuppressWarnings("unchecked")
public static Class<? extends PipelineOptions> getPipelineOptionsInterface(
PipelineOptions options) {
if (options.getClass().getInterfaces().length != 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PipelineOptions interface validation is fairly strict on making sure that methods have the same default/parameter type/...
You should really support multiple interfaces since its quite common in our codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean a pipeline option interface that extends multiple interfaces or the object is implementing multiple interfaces? I couldn't find any example that the pipeline option object is implementing two interfaces. At least if the user uses PipelineOptionsFactory.as() or PipelineOptionsFactory.create() it will return a proxy object that only implements the given interface. (The interface though can be subclass of multiple interfaces itself, and that would be OK.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I know your intent, you should instead check to see if the class is an interface using:
https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#isInterface--

From Class#getInterfaces:
If this object represents an interface, the array contains objects representing all interfaces extended by the interface.

And hence would fail on things like DataflowPipelineOptions which extends multiple interfaces.

Copy link
Contributor Author

@riazela riazela Jun 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I call options.getClass() it will not return DataflowPipelineOptions, it will return a proxy class. For instance BigQueryOptions also extends multiple interfaces (Similar to DataflowPipelineOptions); however, if I run the following code:

BigQueryOptions options = PipelineOptionsFactory.as(BigQueryOptions.class);
System.out.println(options.getClass());
System.out.println(options.getClass().isInterface());
System.out.println(PipelineOptionsReflectionSetter.getPipelineOptionsInterface(options));

There will be no exception and the output will be:
class com.sun.proxy.$Proxy25
false
interface org.apache.beam.sdk.io.gcp.bigquery.BigQueryOptions

The reason that I need this method is when the user tries to use reset command, I should set it to its default value. In order to do that, first I try to see what type of pipelineOptions this object is implementing and then using PipelineOptionsFactory I construct an instance of that options and get its default value.

Currently with our use cases and the expected behavior of PipelineOptionsFactory, this should not fail in any use case. Because the method .as() in PipelineOptions and PipelineOptionsFactory returns a proxy object that implements one interface. I think currently, if the user needs its own piplineOptions they need to declare an interface extending PipelineOptions and then use PipelineOptionsFactory to create an instance of it.

@riazela
Copy link
Contributor Author

riazela commented Jun 28, 2019

run java postcommit

@riazela riazela closed this Jul 9, 2019
@riazela riazela deleted the pipeline_option branch July 18, 2019 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants