diff --git a/go/vt/vtctl/vtctl.go b/go/vt/vtctl/vtctl.go index 48cbd6fddec..e8422d71379 100644 --- a/go/vt/vtctl/vtctl.go +++ b/go/vt/vtctl/vtctl.go @@ -312,13 +312,13 @@ var commands = []commandGroup{ "[-dry_run] [-rename_tables] ", "After a MoveTables or Resharding workflow cleanup unused artifacts like source tables, source shards and blacklists"}, {"CreateLookupVindex", commandCreateLookupVindex, - "[-cell=] [-tablet_types=] ", + "[-cell= DEPRECATED] [-cells=] [-tablet_types=] ", `Create and backfill a lookup vindex. the json_spec must contain the vindex and colvindex specs for the new lookup.`}, {"ExternalizeVindex", commandExternalizeVindex, ".", `Externalize a backfilled vindex.`}, {"Materialize", commandMaterialize, - `, example : '{"workflow": "aaa", "source_keyspace": "source", "target_keyspace": "target", "table_settings": [{"target_table": "customer", "source_expression": "select * from customer", "create_ddl": "copy"}]}'`, + `[-cells=] [-tablet_types=] , example : '{"workflow": "aaa", "source_keyspace": "source", "target_keyspace": "target", "table_settings": [{"target_table": "customer", "source_expression": "select * from customer", "create_ddl": "copy"}]}'`, "Performs materialization based on the json spec. Is used directly to form VReplication rules, with an optional step to copy table structure/DDL."}, {"SplitClone", commandSplitClone, " ", @@ -2263,6 +2263,8 @@ func commandVRWorkflow(ctx context.Context, wr *wrangler.Wrangler, subFlags *fla } func commandCreateLookupVindex(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error { + cells := subFlags.String("cells", "", "Source cells to replicate from.") + //TODO: keep -cell around for backward compatibility and remove it in a future version cell := subFlags.String("cell", "", "Cell to replicate from.") tabletTypes := subFlags.String("tablet_types", "", "Source tablet types to replicate from.") if err := subFlags.Parse(args); err != nil { @@ -2271,6 +2273,9 @@ func commandCreateLookupVindex(ctx context.Context, wr *wrangler.Wrangler, subFl if subFlags.NArg() != 2 { return fmt.Errorf("two arguments are required: keyspace and json_spec") } + if *cells == "" && *cell != "" { + *cells = *cell + } keyspace := subFlags.Arg(0) specs := &vschemapb.Keyspace{} if err := json2.Unmarshal([]byte(subFlags.Arg(1)), specs); err != nil { @@ -2290,6 +2295,8 @@ func commandExternalizeVindex(ctx context.Context, wr *wrangler.Wrangler, subFla } func commandMaterialize(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error { + cells := subFlags.String("cells", "", "Source cells to replicate from.") + tabletTypes := subFlags.String("tablet_types", "", "Source tablet types to replicate from.") if err := subFlags.Parse(args); err != nil { return err } @@ -2300,6 +2307,8 @@ func commandMaterialize(ctx context.Context, wr *wrangler.Wrangler, subFlags *fl if err := json2.Unmarshal([]byte(subFlags.Arg(0)), ms); err != nil { return err } + ms.Cell = *cells + ms.TabletTypes = *tabletTypes return wr.Materialize(ctx, ms) } diff --git a/go/vt/wrangler/materializer_test.go b/go/vt/wrangler/materializer_test.go index 4bfb07357f8..08500a2d80d 100644 --- a/go/vt/wrangler/materializer_test.go +++ b/go/vt/wrangler/materializer_test.go @@ -1574,6 +1574,8 @@ func TestMaterializerOneToOne(t *testing.T) { CreateDdl: "t4ddl", }, }, + Cell: "zone1", + TabletTypes: "master,rdonly", } env := newTestMaterializerEnv(t, ms, []string{"0"}, []string{"0"}) defer env.close() @@ -1590,7 +1592,7 @@ func TestMaterializerOneToOne(t *testing.T) { `rules: `+ `rules: `+ `> ', `)+ - `'', [0-9]*, [0-9]*, '', '', [0-9]*, 0, 'Stopped', 'vt_targetks'`+ + `'', [0-9]*, [0-9]*, 'zone1', 'master,rdonly', [0-9]*, 0, 'Stopped', 'vt_targetks'`+ `\)`+eol, &sqltypes.Result{}, )