cbt: add ability to delete column
Adds ability to delete all cells in a column, effectively deleting the column.
@@ -216,6 +216,13 @@ var commands = []struct {
"into multiple tablets. Can be repeated to create multiple splits.",
Required: cbtconfig.ProjectAndInstanceRequired,
},
+ {
+ Name: "deletecolumn",
+ Desc: "Delete all cells in a column",
+ do: doDeleteColumn,
+ Usage: "cbt deletecolumn <table> <row> <family> <column>",
+ Required: cbtconfig.ProjectAndInstanceRequired,
+ },
{
Name: "deletefamily",
Desc: "Delete a column family",
@@ -367,6 +374,18 @@ func doCreateTable(ctx context.Context, args ...string) {
}
}
+func doDeleteColumn(ctx context.Context, args ...string) {
+ if len(args) != 4 {
+ log.Fatal("usage: cbt deletecolumn <table> <row> <family> <column>")
+ }
+ tbl := getClient().Open(args[0])
+ mut := bigtable.NewMutation()
+ mut.DeleteCellsInColumn(args[2], args[3])
+ if err := tbl.Apply(ctx, args[1], mut); err != nil {
+ log.Fatalf("Deleting cells in column: %v", err)
+ }
+}
+
func doDeleteFamily(ctx context.Context, args ...string) {
if len(args) != 2 {
log.Fatal("usage: cbt deletefamily <table> <family>")
