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

bigtable/bttest: emulator's CreateTable should return columnFamilies in response #1512

Closed
igorbernstein2 opened this issue Jul 20, 2019 · 1 comment
Assignees
Labels
api: bigtable Issues related to the Bigtable API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@igorbernstein2
Copy link
Contributor

Client

Bigtable Emulator

Expected Behavior

The response for a CreateTableRequest should contain the column families of the new table. Currently it only returns the table name

@jeanbza jeanbza added api: bigtable Issues related to the Bigtable API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jul 22, 2019
@odeke-em odeke-em self-assigned this Jul 22, 2019
@odeke-em odeke-em changed the title Bigtable emulator: createtable should return columnFamilies in response bigtable/bttest: emulator's CreateTable should return columnFamilies in response Jul 23, 2019
@odeke-em
Copy link
Contributor

Thank you for this report @igorbernstein2! For posterity, here is a repro that can demonstrate this bug

package main

import (
	"bytes"
	"context"
	"encoding/json"
	"log"
	"reflect"

	durationpb "github.com/golang/protobuf/ptypes/duration"
	btapb "google.golang.org/genproto/googleapis/bigtable/admin/v2"
	"google.golang.org/grpc"
)

func main() {
	ctx := context.Background()
	addr := ":9000"

	conn, err := grpc.Dial(addr, grpc.WithBlock(), grpc.WithInsecure())
	if err != nil {
		log.Fatalf("Failed to dial to grpc service %q: %v", addr, err)
	}
	defer conn.Close()

	btc := btapb.NewBigtableTableAdminClient(conn)
	req := &btapb.CreateTableRequest{
		Parent:  "projects/issue-1512/instances/instance",
		TableId: "issue-1512",
		Table: &btapb.Table{
			ColumnFamilies: map[string]*btapb.ColumnFamily{
				"cf1": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 12}}},
				"cf2": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxAge{MaxAge: &durationpb.Duration{Seconds: 1e8}}}},
			},
		},
	}

	got, err := btc.CreateTable(ctx, req)
	if err != nil {
		log.Fatalf("Failed to create the table: %v", err)
	}

	want := btapb.Table{
		Name: "projects/issue-1512/instances/instance/tables/issue-1512",
		ColumnFamilies: map[string]*btapb.ColumnFamily{
			"cf1": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 12}}},
			"cf2": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxAge{MaxAge: &durationpb.Duration{Seconds: 1e8}}}},
		},
		Granularity: btapb.Table_MILLIS,
	}

	if !reflect.DeepEqual(got, want) {
		gotBlob, _ := json.MarshalIndent(got, "", "  ")
		wantBlob, _ := json.MarshalIndent(want, "", "  ")
		if !bytes.Equal(gotBlob, wantBlob) {
			log.Printf("Response mismatch\n\nGot:\n%s\n\nWant:\n%s\n", gotBlob, wantBlob)
		}
	}
}

which prints out

2019/07/23 13:20:24 Response mismatch

Got:
{
  "name": "projects/issue-1512/instances/instance/tables/issue-1512"
}

Want:
{
  "name": "projects/issue-1512/instances/instance/tables/issue-1512",
  "column_families": {
    "cf1": {
      "gc_rule": {
        "Rule": {
          "MaxNumVersions": 12
        }
      }
    },
    "cf2": {
      "gc_rule": {
        "Rule": {
          "MaxAge": {
            "seconds": 100000000
          }
        }
      }
    }
  },
  "granularity": 1
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the Bigtable API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants