diff --git a/bigtable/admin.go b/bigtable/admin.go index da251c18b431..8dd9f929056f 100644 --- a/bigtable/admin.go +++ b/bigtable/admin.go @@ -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 diff --git a/bigtable/type.go b/bigtable/type.go index dbe97131934e..efd02156e9b6 100644 --- a/bigtable/type.go +++ b/bigtable/type.go @@ -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} } @@ -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_: diff --git a/bigtable/type_test.go b/bigtable/type_test.go index 2ba9eb197dd4..13dff5174b3f 100644 --- a/bigtable/type_test.go +++ b/bigtable/type_test.go @@ -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) } @@ -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) }