Skip to content

feat(bigtable): Support Avro schema bundles in Bigtable's Admin API - #14351

Open
trollyxia wants to merge 3 commits into
googleapis:mainfrom
trollyxia:avro
Open

trollyxia wants to merge 3 commits into
googleapis:mainfrom
trollyxia:avro

Conversation

@trollyxia

Copy link
Copy Markdown
Contributor

No description provided.

@trollyxia
trollyxia requested review from a team as code owners September 10, 2026 21:06

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for Avro schemas in SchemaBundle and its corresponding create and update request builders, along with comprehensive unit and integration tests. The review feedback suggests refining the exception message in SchemaBundle.getAvroSchema() to clearly state that the bundle does not contain an Avro schema, rather than using a generic and potentially misleading message about an invalid type.

@trollyxia trollyxia changed the title feat: Support Avro schema bundles in Bigtable's Admin API feat(bigtable): Support Avro schema bundles in Bigtable's Admin API Sep 10, 2026
}

/** Sets the avro schema for this schema bundle. */
public CreateSchemaBundleRequest setAvroSchema(@Nonnull List<String> avroSchema) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proto schema doesn't have a list override, why is it needed for avro schema?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because their proto definitions differ: http://google3/google/bigtable/admin/v2/table.proto;l=1121-1157;rcl=974104276!

i.e., ProtoSchema defines a single bytes proto_descriptors field, whereas AvroSchema defines a repeated string json_schemas field to accept multiple schema files in a bundle.

Preconditions.checkArgument(
proto.hasProtoSchema(), "Schemabundle must have a proto_schema field");
proto.hasProtoSchema() || proto.hasAvroSchema(),
"Schemabundle must have a proto_schema or avro_schema field");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is proto.hasProtoSchema && proto.hasAvroSchema() also invalid?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In API definition,

proto_schema and avro_schema are defined inside a oneof:

oneof type {
  ProtoSchema proto_schema;
  AvroSchema avro_schema;
}

If the GAPIC correctly translates that into the Java classes, I think there won't be a schema bundle with proto.hasProtoSchema && proto.hasAvroSchema()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in this case, in CreateSchemaBundle, should we validate that avro schema is not set when setting proto schema, vice versa?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Preconditions.checkArgument(
proto.hasProtoSchema(), "Schemabundle must have a proto_schema field");
proto.hasProtoSchema() || proto.hasAvroSchema(),
"Schemabundle must have a proto_schema or avro_schema field");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment?

Preconditions.checkArgument(
proto.hasProtoSchema(), "Schemabundle must have a proto_schema field");
proto.hasProtoSchema() || proto.hasAvroSchema(),
"Schemabundle must have a proto_schema or avro_schema field");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in this case, in CreateSchemaBundle, should we validate that avro schema is not set when setting proto schema, vice versa?

requestBuilder.setSchemaBundle(
com.google.bigtable.admin.v2.SchemaBundle.newBuilder()
.setProtoSchema(ProtoSchema.newBuilder().setProtoDescriptors(protoSchema)));
requestBuilder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we validate that avro schema is not set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


/** Sets the avro schema for this schema bundle. */
public UpdateSchemaBundleRequest setAvroSchema(@Nonnull List<String> avroSchema) {
Preconditions.checkNotNull(avroSchema, "avroSchema must be set");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we validate proto schema is not set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

return setAvroSchema(Collections.singletonList(avroSchema));
}

/** Sets the avro schema for this schema bundle. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sets a list of avro schema for this schema bundle.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants