Skip to content
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
13 changes: 11 additions & 2 deletions go/vt/vtctl/vtctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,13 @@ var commands = []commandGroup{
"[-dry_run] [-rename_tables] <keyspace.workflow>",
"After a MoveTables or Resharding workflow cleanup unused artifacts like source tables, source shards and blacklists"},
{"CreateLookupVindex", commandCreateLookupVindex,
"[-cell=<cell>] [-tablet_types=<source_tablet_types>] <keyspace> <json_spec>",
"[-cell=<source_cells> DEPRECATED] [-cells=<source_cells>] [-tablet_types=<source_tablet_types>] <keyspace> <json_spec>",
`Create and backfill a lookup vindex. the json_spec must contain the vindex and colvindex specs for the new lookup.`},
{"ExternalizeVindex", commandExternalizeVindex,
"<keyspace>.<vindex>",
`Externalize a backfilled vindex.`},
{"Materialize", commandMaterialize,
`<json_spec>, example : '{"workflow": "aaa", "source_keyspace": "source", "target_keyspace": "target", "table_settings": [{"target_table": "customer", "source_expression": "select * from customer", "create_ddl": "copy"}]}'`,
`[-cells=<cells>] [-tablet_types=<source_tablet_types>] <json_spec>, 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,
"<keyspace> <from_shards> <to_shards>",
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
}
Expand All @@ -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)
}

Expand Down
4 changes: 3 additions & 1 deletion go/vt/wrangler/materializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -1590,7 +1592,7 @@ func TestMaterializerOneToOne(t *testing.T) {
`rules:<match:\\"t2\\" filter:\\"select.*t3\\" > `+
`rules:<match:\\"t4\\" > `+
`> ', `)+
`'', [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{},
)
Expand Down