Skip to content

Commit

Permalink
Fixed code for pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
allenc3 committed Jun 12, 2020
1 parent fc75bf0 commit e8b3e68
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
5 changes: 0 additions & 5 deletions google-cloud-bigquerystorage/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@
<className>com/google/cloud/bigquery/storage/v1alpha2/StreamWriter</className>
<method>boolean awaitTermination(long, java.util.concurrent.TimeUnit) </method>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/bigquery/storage/v1alpha2/SchemaCompact</className>
<method>void check(java.lang.String, com.google.protobuf.Descriptors$Descriptor) </method>
</difference>
</differences>
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ private void protoFieldTypeIsCompatibleWithBQFieldType(
* @param allowUnknownFields
* @param protoScope Debugging purposes to show error if messages are nested.
* @param BQScope Debugging purposes to show error if messages are nested.
* @param topLevel True if this is the root level of proto (in terms of nested messages)
* @throws IllegalArgumentException if proto field type is incompatible with BQ field type.
*/
private void isProtoCompatibleWithBQ(
Expand Down Expand Up @@ -526,27 +527,40 @@ private void isProtoCompatibleWithBQ(
/**
* Checks if proto schema is compatible with BQ schema after retrieving BQ schema by BQTableName.
*
* @param BQTableName Must include project_id, dataset_id, and table_id in the form that
matches the regex "projects/([^/]+)/datasets/([^/]+)/tables/([^/]+)"
* @param protoSchema
* @param BQSchema
* @param allowUnknownFields
* @param protoScope Debugging purposes to show error if messages are nested.
* @param BQScope Debugging purposes to show error if messages are nested.
* @param allowUnknownFields Flag indicating proto can have unknown fields.
* @throws IllegalArgumentException if proto field type is incompatible with BQ field type.
*/
public void check(
String BQTableName, Descriptors.Descriptor protoSchema, boolean allowUnknownFields)
throws IllegalArgumentException {

Table table = bigquery.getTable(getTableId(BQTableName));
Schema BQSchema = table.getDefinition().getSchema();
String protoSchemaName = protoSchema.getName();
isSupported(protoSchema);
isProtoCompatibleWithBQ(
protoSchema,
BQSchema,
allowUnknownFields,
protoSchemaName,
protoSchema.getName(),
getTableId(BQTableName).getTable(),
true);
}

/**
* Checks if proto schema is compatible with BQ schema after retrieving BQ schema by BQTableName.
* Assumes allowUnknownFields is false.
*
* @param BQTableName Must include project_id, dataset_id, and table_id in the form that
matches the regex "projects/([^/]+)/datasets/([^/]+)/tables/([^/]+)"
* @param protoSchema
* @throws IllegalArgumentException if proto field type is incompatible with BQ field type.
*/
public void check(
String BQTableName, Descriptors.Descriptor protoSchema)
throws IllegalArgumentException {

check(BQTableName, protoSchema, false);
}
}

0 comments on commit e8b3e68

Please sign in to comment.