Ejemplo n.º 1
0
  @Override
  public void renameTable(ConnectorTableHandle tableHandle, SchemaTableName newTableName) {
    if (!allowRenameTable) {
      throw new PrestoException(
          PERMISSION_DENIED, "Renaming tables is disabled in this Hive catalog");
    }

    HiveTableHandle handle = checkType(tableHandle, HiveTableHandle.class, "tableHandle");
    metastore.renameTable(
        handle.getSchemaName(),
        handle.getTableName(),
        newTableName.getSchemaName(),
        newTableName.getTableName());
  }
Ejemplo n.º 2
0
  @Override
  public void dropTable(ConnectorTableHandle tableHandle) {
    HiveTableHandle handle = checkType(tableHandle, HiveTableHandle.class, "tableHandle");
    SchemaTableName tableName = schemaTableName(tableHandle);

    if (!allowDropTable) {
      throw new PrestoException(PERMISSION_DENIED, "DROP TABLE is disabled in this Hive catalog");
    }

    try {
      Table table = metastore.getTable(handle.getSchemaName(), handle.getTableName());
      if (!handle.getSession().getUser().equals(table.getOwner())) {
        throw new PrestoException(
            PERMISSION_DENIED,
            format(
                "Unable to drop table '%s': owner of the table is different from session user",
                table));
      }
      metastore.dropTable(handle.getSchemaName(), handle.getTableName());
    } catch (NoSuchObjectException e) {
      throw new TableNotFoundException(tableName);
    }
  }