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

fix: BQTableSchemaToProtoDescriptor setting of FieldOption. #2743

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading