robinyqiu commented on a change in pull request #12237:
URL: https://github.com/apache/beam/pull/12237#discussion_r453821984
##########
File path:
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/PubsubSchemaCapableIOProvider.java
##########
@@ -116,11 +116,21 @@ public Schema configurationSchema() {
public PubsubSchemaIO from(String location, Row configuration, Schema
dataSchema) {
validateConfigurationSchema(configuration);
validateDlq(configuration.getValue("deadLetterQueue"));
- validateEventTimestamp(dataSchema);
+ validateDataSchema(dataSchema);
return new PubsubSchemaIO(location, configuration, dataSchema);
}
- private void validateEventTimestamp(Schema schema) {
+ @Override
+ public Boolean requiresDataSchema() {
+ return true;
+ }
+
+ private void validateDataSchema(Schema schema) {
+ if (requiresDataSchema() && schema == null) {
Review comment:
Consider removing `requiresDataSchema()` because it is always true here?
I know this is the general logic but in this specific provider this call is
not necessary.
##########
File path:
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/io/SchemaIOProvider.java
##########
@@ -47,5 +48,8 @@
* resides there, and some IO-specific configuration object. Can throw a
{@link
* InvalidConfigurationException} or a {@link InvalidSchemaException}.
*/
- SchemaIO from(String location, Row configuration, Schema dataSchema);
+ SchemaIO from(String location, Row configuration, @Nullable Schema
dataSchema);
+
+ /** Indicates whether the dataSchema value is necessary. */
+ Boolean requiresDataSchema();
Review comment:
Prefer return primitive `boolean` type?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]