Skip to content

Commit

Permalink
fix: BQTableSchemaToProtoDescriptor setting of FieldOption. (#2743)
Browse files Browse the repository at this point in the history
This is to unblock protocol buffer version updates.
  • Loading branch information
PhongChuong authored Oct 28, 2024
1 parent 857c751 commit fb57909
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.google.protobuf.Descriptors;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.ExtensionLite;
import com.google.protobuf.Message;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -217,13 +217,13 @@ private static FieldDescriptorProto convertBQTableFieldToProtoField(
// Sets columnName annotation when field name is not proto comptaible.
if (!BigQuerySchemaUtil.isProtoCompatible(fieldName)) {
fieldDescriptor.setName(BigQuerySchemaUtil.generatePlaceholderFieldName(fieldName));
fieldDescriptor.setOptions(
FieldOptions.newBuilder()
.setExtension(
(ExtensionLite<FieldOptions, String>) AnnotationsProto.columnName,
// Remove ExtensionLite after protobuf linkage error is resolved.
fieldName)
.build());

// The following work around (instead of setting FieldOptions directly) for when
// FieldOptions.Builder changes from GeneratedMessageV3 in 3.25 to GeneratedMessage in 4.28 as
// it no longer depends on FieldOptions.
Message.Builder fieldOptionBuilder = FieldOptions.newBuilder();
fieldOptionBuilder.setField(AnnotationsProto.columnName.getDescriptor(), fieldName);
fieldDescriptor.setOptions((FieldOptions) fieldOptionBuilder.build());
}
return fieldDescriptor.build();
}
Expand Down

0 comments on commit fb57909

Please sign in to comment.