Altering Column Families in JSON Tables

You can alter column families, including the default column family for a table, by using either of two methods.

  • Run the command maprcli table cf edit.
  • Use the Admin.alterFamily() method in the MapR-DB JSON Java API Library.

Permissions Required

The readAce and writeAce permissions on the volumes where the JSON tables are located. For information about how to set permissions on volumes, see Setting/Modifying Whole Volume ACEs.

Example

Here is an example of using the API to change the name of a column family:

public void alterColumnFamily(String tablePath, String familyName,
  String newFamilyName) throws DBException {
  try (Admin admin = MapRDB.newAdmin()) {

    /* Get a TableDescriptor object for the table. This object
       gives access to the column families that are in the table. */ 
    TableDescriptor tableDesc = admin.getTableDescriptor(tablePath);

    /* Get a FamilyDescriptor object for the column family to
       change the name of. /
    FamilyDescriptor familyDesc = tableDesc.getFamily(familyName);

    // Rename the column family.
    familyDesc.setName(newFamilyName);

    /* Call alterFamily(), passing in the path of the table,
       the original name of the column family, and the 
       FamilyDescriptor in which the new name was set. */
    admin.alterFamily(tablePath, familyName, familyDesc);
  }
}