Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.
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 @@ -505,16 +505,19 @@ public int hashCode() {
abstract class SchemalessProto implements SqlType.Proto {

public static SchemalessProto fromProto(com.google.bigtable.v2.Type.Proto proto) {
return create(proto.getMessageName());
return create(proto.getMessageName(), proto.getSchemaBundleId());
}

public static SchemalessProto create(java.lang.String messageName) {
return new AutoValue_Type_SchemalessProto(messageName);
public static SchemalessProto create(
java.lang.String messageName, java.lang.String schemaBundleId) {
return new AutoValue_Type_SchemalessProto(messageName, schemaBundleId);
}

@Override
public abstract java.lang.String getMessageName();

public abstract java.lang.String schemaBundleId();

@Override
public Parser<AbstractMessage> getParserForType() {
throw new UnsupportedOperationException(
Expand All @@ -529,7 +532,12 @@ public Code getCode() {

@Override
public java.lang.String toString() {
return getCode().name() + "{messageName=" + getMessageName() + "}";
return getCode().name()
+ "{messageName="
+ getMessageName()
+ ", schemaBundleId="
+ schemaBundleId()
+ "}";
}
}

Expand All @@ -544,15 +552,18 @@ public java.lang.String toString() {
abstract class SchemalessEnum implements SqlType.Enum {

public static SchemalessEnum fromProto(com.google.bigtable.v2.Type.Enum proto) {
return create(proto.getEnumName());
return create(proto.getEnumName(), proto.getSchemaBundleId());
}

public static SchemalessEnum create(java.lang.String enumName) {
return new AutoValue_Type_SchemalessEnum(enumName);
public static SchemalessEnum create(
java.lang.String enumName, java.lang.String schemaBundleId) {
return new AutoValue_Type_SchemalessEnum(enumName, schemaBundleId);
}

public abstract java.lang.String getEnumName();

public abstract java.lang.String schemaBundleId();

@Override
public Function<Integer, ProtocolMessageEnum> getForNumber() {
throw new UnsupportedOperationException(
Expand All @@ -567,7 +578,12 @@ public Code getCode() {

@Override
public java.lang.String toString() {
return getCode().name() + "{enumName=" + getEnumName() + "}";
return getCode().name()
+ "{enumName="
+ getEnumName()
+ ", schemaBundleId="
+ schemaBundleId()
+ "}";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ public void simpleTypes_TypeToString() {
assertThat(Type.Timestamp.create().toString()).isEqualTo("TIMESTAMP");
assertThat(Type.Date.create().toString()).isEqualTo("DATE");
assertThat(Type.SchemalessStruct.create().toString()).isEqualTo("STRUCT");
assertThat(Type.SchemalessProto.create("MyMessage").toString())
.isEqualTo("PROTO{messageName=MyMessage}");
assertThat(Type.SchemalessEnum.create("MyEnum").toString()).isEqualTo("ENUM{enumName=MyEnum}");
assertThat(Type.SchemalessProto.create("MyMessage", "my_bundle").toString())
.isEqualTo("PROTO{messageName=MyMessage, schemaBundleId=my_bundle}");
assertThat(Type.SchemalessEnum.create("MyEnum", "other_bundle").toString())
.isEqualTo("ENUM{enumName=MyEnum, schemaBundleId=other_bundle}");
}

@Test
Expand Down Expand Up @@ -123,37 +124,48 @@ public void map_equals() {

@Test
public void proto_equals() {
assertThat(Type.SchemalessProto.create("MyMessage"))
.isEqualTo(Type.SchemalessProto.create("MyMessage"));
assertThat(Type.SchemalessProto.create("MyMessage", "my_bundle"))
.isEqualTo(Type.SchemalessProto.create("MyMessage", "my_bundle"));
assertThat(Type.Proto.create(Singer.getDefaultInstance()))
.isEqualTo(Type.Proto.create(Singer.getDefaultInstance()));

assertThat(Type.SchemalessProto.create("MyMessage"))
.isNotEqualTo(Type.SchemalessProto.create("AnotherMessage"));
assertThat(Type.SchemalessProto.create("MyMessage", "my_bundle"))
.isNotEqualTo(Type.SchemalessProto.create("AnotherMessage", "my_bundle"));
assertThat(Type.SchemalessProto.create("MyMessage", "my_bundle"))
.isNotEqualTo(Type.SchemalessProto.create("MyMessage", "another_bundle"));
assertThat(Type.Proto.create(Singer.getDefaultInstance()))
.isNotEqualTo(Type.Proto.create(Album.getDefaultInstance()));

assertThat(Type.SchemalessProto.create("com.google.cloud.bigtable.data.v2.test.Singer"))
assertThat(
Type.SchemalessProto.create(
"com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle"))
.isNotEqualTo(Type.Proto.create(Singer.getDefaultInstance()));
assertThat(Type.Proto.create(Singer.getDefaultInstance()))
.isNotEqualTo(Type.SchemalessProto.create("com.google.cloud.bigtable.data.v2.test.Singer"));
.isNotEqualTo(
Type.SchemalessProto.create(
"com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle"));
}

@Test
public void enum_equals() {
assertThat(Type.SchemalessEnum.create("MyEnum"))
.isEqualTo(Type.SchemalessEnum.create("MyEnum"));
assertThat(Type.SchemalessEnum.create("MyEnum", "my_bundle"))
.isEqualTo(Type.SchemalessEnum.create("MyEnum", "my_bundle"));
assertThat(Type.Enum.create(Genre::forNumber)).isEqualTo(Type.Enum.create(Genre::forNumber));

assertThat(Type.SchemalessEnum.create("MyEnum"))
.isNotEqualTo(Type.SchemalessEnum.create("AnotherEnum"));
assertThat(Type.SchemalessEnum.create("MyEnum", "my_bundle"))
.isNotEqualTo(Type.SchemalessEnum.create("AnotherEnum", "my_bundle"));
assertThat(Type.SchemalessEnum.create("MyEnum", "my_bundle"))
.isNotEqualTo(Type.SchemalessEnum.create("MyEnum", "another_bundle"));
assertThat(Type.Enum.create(Genre::forNumber))
.isNotEqualTo(Type.Enum.create(Format::forNumber));

assertThat(Type.SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre"))
assertThat(
Type.SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre", "my_bundle"))
.isNotEqualTo(Type.Enum.create(Genre::forNumber));
assertThat(Type.Enum.create(Genre::forNumber))
.isNotEqualTo(Type.SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre"));
.isNotEqualTo(
Type.SchemalessEnum.create(
"com.google.cloud.bigtable.data.v2.test.Genre", "my_bundle"));
}

@Test
Expand Down Expand Up @@ -230,13 +242,13 @@ public void schemalessStruct_throwsExceptionOnSchemaAccess() {

@Test
public void schemalessProto_throwsExceptionOnGetParser() {
SchemalessProto proto = Type.SchemalessProto.create("MyMessage");
SchemalessProto proto = Type.SchemalessProto.create("MyMessage", "my_bundle");
assertThrows(UnsupportedOperationException.class, proto::getParserForType);
}

@Test
public void schemalessEnum_throwsExceptionOnGetForNumber() {
SchemalessEnum myEnum = Type.SchemalessEnum.create("MyEnum");
SchemalessEnum myEnum = Type.SchemalessEnum.create("MyEnum", "my_bundle");
assertThrows(UnsupportedOperationException.class, myEnum::getForNumber);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ public void mapField_accessingProto() {
"testField",
mapType(
bytesType(),
protoType("com.google.cloud.bigtable.data.v2.test.Singer"))))),
protoType(
"com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle"))))),
Collections.singletonList(
mapValue(mapElement(bytesValue("key"), bytesValue(singer.toByteArray())))));
HashMap<ByteString, Singer> expectedMap = new HashMap<>();
Expand All @@ -280,15 +281,17 @@ public void mapField_accessingProto() {
"testField",
SqlType.mapOf(
SqlType.bytes(),
SchemalessProto.create("com.google.cloud.bigtable.data.v2.test.Singer"))));
SchemalessProto.create(
"com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle"))));
assertThrows(
UnsupportedOperationException.class,
() ->
structWithMap.getMap(
0,
SqlType.mapOf(
SqlType.bytes(),
SchemalessProto.create("com.google.cloud.bigtable.data.v2.test.Singer"))));
SchemalessProto.create(
"com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle"))));
assertThrows(
IllegalStateException.class,
() ->
Expand Down Expand Up @@ -319,7 +322,8 @@ public void mapField_accessingEnum() {
"testField",
mapType(
bytesType(),
enumType("com.google.cloud.bigtable.data.v2.test.Genre"))))),
enumType(
"com.google.cloud.bigtable.data.v2.test.Genre", "my_bundle"))))),
Collections.singletonList(mapValue(mapElement(bytesValue("key"), int64Value(0)))));
HashMap<ByteString, Genre> expectedMap = new HashMap<>();
expectedMap.put(ByteString.copyFromUtf8("key"), Genre.POP);
Expand All @@ -340,31 +344,35 @@ public void mapField_accessingEnum() {
"testField",
SqlType.mapOf(
SqlType.bytes(),
SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre"))));
SchemalessEnum.create(
"com.google.cloud.bigtable.data.v2.test.Genre", "my_bundle"))));
assertThrows(
UnsupportedOperationException.class,
() ->
structWithMap.getMap(
0,
SqlType.mapOf(
SqlType.bytes(),
SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre"))));
SchemalessEnum.create(
"com.google.cloud.bigtable.data.v2.test.Genre", "my_bundle"))));
assertThrows(
UnsupportedOperationException.class,
() ->
structWithMap.getMap(
"testField",
SqlType.mapOf(
SqlType.bytes(),
SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre"))));
SchemalessEnum.create(
"com.google.cloud.bigtable.data.v2.test.Genre", "my_bundle"))));
assertThrows(
UnsupportedOperationException.class,
() ->
structWithMap.getMap(
0,
SqlType.mapOf(
SqlType.bytes(),
SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre"))));
SchemalessEnum.create(
"com.google.cloud.bigtable.data.v2.test.Genre", "my_bundle"))));
assertThrows(
IllegalStateException.class,
() -> structWithMap.getMap("testField", SqlType.mapOf(SqlType.bytes(), SqlType.bytes())));
Expand Down Expand Up @@ -481,8 +489,8 @@ public static List<Object[]> parameters() {
structField("stringField", stringType()),
structField("intField", int64Type()),
structField("listField", arrayType(stringType())),
structField("protoField", protoType("MyMessage")),
structField("enumField", enumType("MyEnum"))))),
structField("protoField", protoType("MyMessage", "my_bundle")),
structField("enumField", enumType("MyEnum", "other_bundle"))))),
Collections.singletonList(
arrayValue(
stringValue("test"),
Expand All @@ -501,8 +509,8 @@ public static List<Object[]> parameters() {
structField("stringField", stringType()),
structField("intField", int64Type()),
structField("listField", arrayType(stringType())),
structField("protoField", protoType("MyMessage")),
structField("enumField", enumType("MyEnum")))),
structField("protoField", protoType("MyMessage", "my_bundle")),
structField("enumField", enumType("MyEnum", "other_bundle")))),
arrayValue(
stringValue("test"),
int64Value(100),
Expand Down Expand Up @@ -686,7 +694,8 @@ public static List<Object[]> parameters() {
{
Collections.singletonList(
columnMetadata(
"testField", protoType("com.google.cloud.bigtable.data.v2.test.Singer"))),
"testField",
protoType("com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle"))),
Collections.singletonList(
bytesValue(
Singer.newBuilder()
Expand All @@ -707,7 +716,9 @@ public static List<Object[]> parameters() {
Collections.singletonList(
columnMetadata(
"testField",
arrayType(protoType("com.google.cloud.bigtable.data.v2.test.Singer")))),
arrayType(
protoType(
"com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle")))),
Collections.singletonList(
arrayValue(
bytesValue(
Expand Down Expand Up @@ -743,7 +754,8 @@ public static List<Object[]> parameters() {
"testField",
mapType(
bytesType(),
protoType("com.google.cloud.bigtable.data.v2.test.Singer")))),
protoType(
"com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle")))),
Collections.singletonList(
mapValue(
mapElement(
Expand Down Expand Up @@ -791,7 +803,8 @@ public static List<Object[]> parameters() {
{
Collections.singletonList(
columnMetadata(
"testField", enumType("com.google.cloud.bigtable.data.v2.test.Genre"))),
"testField",
enumType("com.google.cloud.bigtable.data.v2.test.Genre", "my_bundle"))),
Collections.singletonList(int64Value(1)),
0,
"testField",
Expand All @@ -806,7 +819,8 @@ public static List<Object[]> parameters() {
Collections.singletonList(
columnMetadata(
"testField",
arrayType(enumType("com.google.cloud.bigtable.data.v2.test.Genre")))),
arrayType(
enumType("com.google.cloud.bigtable.data.v2.test.Genre", "my_bundle")))),
Collections.singletonList(arrayValue(nullValue(), int64Value(2), int64Value(100))),
0,
"testField",
Expand All @@ -824,7 +838,8 @@ public static List<Object[]> parameters() {
columnMetadata(
"testField",
mapType(
bytesType(), enumType("com.google.cloud.bigtable.data.v2.test.Genre")))),
bytesType(),
enumType("com.google.cloud.bigtable.data.v2.test.Genre", "my_bundle")))),
Collections.singletonList(
mapValue(
mapElement(bytesValue("foo"), int64Value(1)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ public class ProtoStructTest {
structField("listField", arrayType(stringType())),
structField("mapField", mapType(stringType(), stringType())),
structField(
"protoField", protoType("com.google.cloud.bigtable.data.v2.test.Singer")),
"protoField",
protoType("com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle")),
structField(
"enumField", enumType("com.google.cloud.bigtable.data.v2.test.Genre")))),
"enumField",
enumType(
"com.google.cloud.bigtable.data.v2.test.Genre", "other_bundle")))),
arrayValue(
bytesValue("testBytes"),
stringValue("testString"),
Expand Down Expand Up @@ -184,9 +187,11 @@ public void getColumnType_byName() {
assertThat(struct.getColumnType("mapField"))
.isEqualTo(SqlType.mapOf(SqlType.string(), SqlType.string()));
assertThat(struct.getColumnType("protoField"))
.isEqualTo(SchemalessProto.create("com.google.cloud.bigtable.data.v2.test.Singer"));
.isEqualTo(
SchemalessProto.create("com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle"));
assertThat(struct.getColumnType("enumField"))
.isEqualTo(SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre"));
.isEqualTo(
SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre", "other_bundle"));
}

@Test
Expand All @@ -205,9 +210,11 @@ public void getColumnType_byIndex() {
assertThat(struct.getColumnType(10))
.isEqualTo(SqlType.mapOf(SqlType.string(), SqlType.string()));
assertThat(struct.getColumnType(11))
.isEqualTo(SchemalessProto.create("com.google.cloud.bigtable.data.v2.test.Singer"));
.isEqualTo(
SchemalessProto.create("com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle"));
assertThat(struct.getColumnType(12))
.isEqualTo(SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre"));
.isEqualTo(
SchemalessEnum.create("com.google.cloud.bigtable.data.v2.test.Genre", "other_bundle"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ public void testSingleRow() throws ExecutionException, InterruptedException {
columnMetadata("struct", structType(structField("string", stringType()))),
columnMetadata("list", arrayType(stringType())),
columnMetadata("map", mapType(stringType(), stringType())),
columnMetadata("proto", protoType("com.google.cloud.bigtable.data.v2.test.Singer")),
columnMetadata("enum", enumType("com.google.cloud.bigtable.data.v2.test.Genre")));
columnMetadata(
"proto", protoType("com.google.cloud.bigtable.data.v2.test.Singer", "my_bundle")),
columnMetadata(
"enum", enumType("com.google.cloud.bigtable.data.v2.test.Genre", "other_bundle")));
ResultSetMetadata metadata = ProtoResultSetMetadata.fromProto(protoMetadata);
ResultSet resultSet =
resultSetWithFakeStream(
Expand Down
Loading
Loading