Skip to content

Commit

Permalink
feat(bigtable): expose protoToType (#10602)
Browse files Browse the repository at this point in the history
* feat(bigtable): expose protoToType

* add comment to ProtoToType
  • Loading branch information
ron-gal authored Jul 29, 2024
1 parent 0211c95 commit 643a8e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bigtable/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ func (ac *AdminClient) TableInfo(ctx context.Context, table string) (*TableInfo,
Name: name,
GCPolicy: GCRuleToString(fam.GcRule),
FullGCPolicy: gcRuleToPolicy(fam.GcRule),
ValueType: protoToType(fam.ValueType),
ValueType: ProtoToType(fam.ValueType),
})
}
// we expect DeletionProtection to be in the response because Table_SCHEMA_VIEW is being used in this function
Expand Down
5 changes: 3 additions & 2 deletions bigtable/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ func (agg AggregateType) proto() *btapb.Type {
return &btapb.Type{Kind: &btapb.Type_AggregateType{AggregateType: protoAgg}}
}

func protoToType(pb *btapb.Type) Type {
// ProtoToType converts a protobuf *btapb.Type to an instance of the Type interface, for use of the admin API.
func ProtoToType(pb *btapb.Type) Type {
if pb == nil {
return unknown[btapb.Type]{wrapped: nil}
}
Expand Down Expand Up @@ -254,7 +255,7 @@ func aggregateProtoToType(agg *btapb.Type_Aggregate) Type {
return AggregateType{Input: nil, Aggregator: unknownAggregator{wrapped: agg}}
}

it := protoToType(agg.InputType)
it := ProtoToType(agg.InputType)
var aggregator Aggregator
switch agg.Aggregator.(type) {
case *btapb.Type_Aggregate_Sum_:
Expand Down
8 changes: 4 additions & 4 deletions bigtable/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestSumAggregateProto(t *testing.T) {

func TestProtoBijection(t *testing.T) {
want := aggregateProto()
got := protoToType(want).proto()
got := ProtoToType(want).proto()
if !proto.Equal(got, want) {
t.Errorf("got type %v, want: %v", got, want)
}
Expand Down Expand Up @@ -223,11 +223,11 @@ func TestHllAggregateProto(t *testing.T) {
}

func TestNilChecks(t *testing.T) {
// protoToType
if val, ok := protoToType(nil).(unknown[btapb.Type]); !ok {
// ProtoToType
if val, ok := ProtoToType(nil).(unknown[btapb.Type]); !ok {
t.Errorf("got: %T, wanted unknown[btapb.Type]", val)
}
if val, ok := protoToType(&btapb.Type{}).(unknown[btapb.Type]); !ok {
if val, ok := ProtoToType(&btapb.Type{}).(unknown[btapb.Type]); !ok {
t.Errorf("got: %T, wanted unknown[btapb.Type]", val)
}

Expand Down

0 comments on commit 643a8e3

Please sign in to comment.