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:update schema compat check with backend type changes #522

Merged
merged 2 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
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 @@ -156,8 +156,8 @@ private static boolean isCompatibleWithBQDate(Descriptors.FieldDescriptor.Type f
}

private static boolean isCompatibleWithBQDatetime(Descriptors.FieldDescriptor.Type field) {
if (field == Descriptors.FieldDescriptor.Type.INT64
|| field == Descriptors.FieldDescriptor.Type.SFIXED64) {
if (field == Descriptors.FieldDescriptor.Type.STRING
|| field == Descriptors.FieldDescriptor.Type.INT64) {
return true;
}
return false;
Expand All @@ -174,7 +174,7 @@ private static boolean isCompatibleWithBQFloat(Descriptors.FieldDescriptor.Type
}

private static boolean isCompatibleWithBQGeography(Descriptors.FieldDescriptor.Type field) {
if (field == Descriptors.FieldDescriptor.Type.BYTES) {
if (field == Descriptors.FieldDescriptor.Type.STRING) {
return true;
}
return false;
Expand All @@ -201,15 +201,10 @@ private static boolean isCompatibleWithBQNumeric(Descriptors.FieldDescriptor.Typ
|| field == Descriptors.FieldDescriptor.Type.FIXED32
|| field == Descriptors.FieldDescriptor.Type.FIXED64
|| field == Descriptors.FieldDescriptor.Type.SFIXED32
|| field == Descriptors.FieldDescriptor.Type.SFIXED64) {
return true;
}

if (field == Descriptors.FieldDescriptor.Type.BYTES) {
return true;
}

if (field == Descriptors.FieldDescriptor.Type.FLOAT
|| field == Descriptors.FieldDescriptor.Type.SFIXED64
|| field == Descriptors.FieldDescriptor.Type.STRING
|| field == Descriptors.FieldDescriptor.Type.BYTES
|| field == Descriptors.FieldDescriptor.Type.FLOAT
|| field == Descriptors.FieldDescriptor.Type.DOUBLE) {
return true;
}
Expand All @@ -235,7 +230,7 @@ private static boolean isCompatibleWithBQString(Descriptors.FieldDescriptor.Type

private static boolean isCompatibleWithBQTime(Descriptors.FieldDescriptor.Type field) {
if (field == Descriptors.FieldDescriptor.Type.INT64
|| field == Descriptors.FieldDescriptor.Type.SFIXED64) {
|| field == Descriptors.FieldDescriptor.Type.STRING) {

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ public void testBQDatetime() {
.build()));
SchemaCompatibility compact = SchemaCompatibility.getInstance(mockBigquery);
HashSet<Descriptors.Descriptor> compatible =
new HashSet<>(Arrays.asList(Int64Type.getDescriptor(), SFixed64Type.getDescriptor()));
new HashSet<>(Arrays.asList(Int64Type.getDescriptor(), StringType.getDescriptor()));

for (Descriptors.Descriptor descriptor : type_descriptors) {
if (compatible.contains(descriptor)) {
Expand Down Expand Up @@ -649,7 +649,7 @@ public void testBQGeography() {
.build()));
SchemaCompatibility compact = SchemaCompatibility.getInstance(mockBigquery);
HashSet<Descriptors.Descriptor> compatible =
new HashSet<>(Arrays.asList(BytesType.getDescriptor()));
new HashSet<>(Arrays.asList(StringType.getDescriptor()));

for (Descriptors.Descriptor descriptor : type_descriptors) {
if (compatible.contains(descriptor)) {
Expand Down Expand Up @@ -730,6 +730,7 @@ public void testBQNumeric() {
SFixed32Type.getDescriptor(),
SFixed64Type.getDescriptor(),
BytesType.getDescriptor(),
StringType.getDescriptor(),
FloatType.getDescriptor(),
DoubleType.getDescriptor()));

Expand Down Expand Up @@ -879,7 +880,7 @@ public void testBQTime() {
.build()));
SchemaCompatibility compact = SchemaCompatibility.getInstance(mockBigquery);
HashSet<Descriptors.Descriptor> compatible =
new HashSet<>(Arrays.asList(Int64Type.getDescriptor(), SFixed64Type.getDescriptor()));
new HashSet<>(Arrays.asList(Int64Type.getDescriptor(), StringType.getDescriptor()));

for (Descriptors.Descriptor descriptor : type_descriptors) {
if (compatible.contains(descriptor)) {
Expand Down