Borra un grupo familiar

Borra una familia de columnas.

Muestra de código

C#

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente de Bigtable, consulta las bibliotecas cliente de Bigtable.

// Delete a column family.
// Initialize request argument(s).
GcRule maxVersionsRule = new GcRule { MaxNumVersions = 1 };

TableName tableName = new TableName(projectId, instanceId, tableId);

// Modification to update column family
ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification
{
    Drop = true,
    Id = "cf2"
};

ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest
{
    TableName = tableName,
    Modifications = { modification }
};
try
{
    // Make the request
    Table response = bigtableTableAdminClient.ModifyColumnFamilies(request);
    Console.WriteLine("Deleted column family");
}
catch (Exception ex)
{
    Console.WriteLine($"Error deleting column family {ex.Message}");
}

C++

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente de Bigtable, consulta las bibliotecas cliente de Bigtable.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::TableAdmin admin, std::string const& table_id,
   std::string const& family_name) {
  StatusOr<google::bigtable::admin::v2::Table> schema =
      admin.ModifyColumnFamilies(
          table_id, {cbt::ColumnFamilyModification::Drop(family_name)});

  if (!schema) throw std::runtime_error(schema.status().message());
  std::cout << "Schema modified to: " << schema->DebugString() << "\n";
}

Java

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente de Bigtable, consulta las bibliotecas cliente de Bigtable.

// Deletes a column family.
try {
  ModifyColumnFamiliesRequest deleted =
      ModifyColumnFamiliesRequest.of(tableId).dropFamily(COLUMN_FAMILY_2);
  adminClient.modifyFamilies(deleted);
  System.out.printf("Column family %s deleted successfully%n", COLUMN_FAMILY_2);
} catch (NotFoundException e) {
  System.err.println("Failed to delete a non-existent column family: " + e.getMessage());
}

Node.js

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente de Bigtable, consulta las bibliotecas cliente de Bigtable.

// Delete a column family
await family.delete();
console.log(`${family.id} deleted successfully\n`);

PHP

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente de Bigtable, consulta las bibliotecas cliente de Bigtable.

use Google\Cloud\Bigtable\Admin\V2\ModifyColumnFamiliesRequest\Modification;
use Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient;

/**
 * Delete a column family in a table
 *
 * @param string $projectId The Google Cloud project ID
 * @param string $instanceId The ID of the Bigtable instance
 * @param string $tableId The ID of the table where the column family needs to be deleted
 * @param string $familyId The ID of the column family to be deleted
 */
function delete_family(
    string $projectId,
    string $instanceId,
    string $tableId,
    string $familyId = 'cf2'
): void {
    $tableAdminClient = new BigtableTableAdminClient();
    $tableName = $tableAdminClient->tableName($projectId, $instanceId, $tableId);

    print("Delete a column family $familyId..." . PHP_EOL);
    // Delete a column family
    $columnModification = new Modification();
    $columnModification->setId($familyId);
    $columnModification->setDrop(true);
    $tableAdminClient->modifyColumnFamilies($tableName, [$columnModification]);
    print("Column family $familyId deleted successfully." . PHP_EOL);
}

Python

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente de Bigtable, consulta las bibliotecas cliente de Bigtable.

print('Delete a column family cf2...')
# Delete a column family
column_family2.delete()
print('Column family cf2 deleted successfully.')

Ruby

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente de Bigtable, consulta las bibliotecas cliente de Bigtable.

column_families = table.column_families do |cfs|
  cfs.delete "cf2"
end

¿Qué sigue?

Para buscar y filtrar muestras de código para otros productos de Google Cloud, consulta el navegador de muestra de Google Cloud.