-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Make defaults for optional SchemaTransformProvider methods #30560
Changes from 4 commits
9e79bdd
ab09afa
b3ed202
781096d
6131a76
513f214
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ | |
*/ | ||
package org.apache.beam.sdk.schemas.transforms; | ||
|
||
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument; | ||
|
||
import java.lang.reflect.ParameterizedType; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.apache.beam.sdk.annotations.Internal; | ||
|
@@ -39,7 +42,16 @@ | |
@Internal | ||
public abstract class TypedSchemaTransformProvider<ConfigT> implements SchemaTransformProvider { | ||
|
||
protected abstract Class<ConfigT> configurationClass(); | ||
@SuppressWarnings("unchecked") | ||
protected Class<ConfigT> configurationClass() { | ||
Optional<ParameterizedType> parameterizedType = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you just put it in an @Nullable ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
checkStateNotNull(superClass, "Could not ...");
return (Class<ConfigT>) parameterizedType.getActualTypeArguments[0]; FWIW I am not sure if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, applied the suggestion. |
||
Optional.ofNullable((ParameterizedType) getClass().getGenericSuperclass()); | ||
checkArgument( | ||
parameterizedType.isPresent(), | ||
"Could not get the TypedSchemaTransformProvider's parameterized type."); | ||
|
||
return (Class<ConfigT>) parameterizedType.get().getActualTypeArguments()[0]; | ||
} | ||
|
||
/** | ||
* Produce a SchemaTransform from ConfigT. Can throw a {@link InvalidConfigurationException} or a | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ | |
import org.junit.runners.JUnit4; | ||
|
||
@RunWith(JUnit4.class) | ||
public class BigQueryStorageWriteApiSchemaTransformProviderTest { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This breaks DataflowV1 and V2 tests. Any reason moving them from unit test to integration test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CC: @ahmedabu98 @kennknowles @damondouglas They use fake BigQuery service so has to be executed locally. Either exclude them from Dataflow test suites or move back to unit test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh no reason, bad mistake. I'll open a PR to revert this part There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for catching this, pls take a look at #30623 |
||
public class BigQueryStorageWriteApiSchemaTransformProviderIT { | ||
|
||
private FakeDatasetService fakeDatasetService = new FakeDatasetService(); | ||
private FakeJobService fakeJobService = new FakeJobService(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intellij thinks these methods are unused - is intellij wrong? or could they be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In reality, developers make their providers by extending TypedSchemaTransformProvider, which implements SchemaTransformProvider. I guess intellij might grey it out because they're not directly used from SchemaTransformProvider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if they override these methods but we never call them, does it matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh these methods are eventually called by the expansion service to create the discover response. Reference here:
beam/sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/ExpansionService.java
Lines 733 to 734 in fedca3c