Package org.apache.hive.hcatalog.common

Examples of org.apache.hive.hcatalog.common.HCatException


        if (currentParts.size() > 0) {
          // If a table is partitioned and immutable, then the presence
          // of the partition alone is enough to throw an error - we do
          // not need to check for emptiness to decide to throw an error
          throw new HCatException(ErrorType.ERROR_DUPLICATE_PARTITION);
        }
      }
    } else {
      List<String> partitionValues = getPartitionValueList(
        table, outputInfo.getPartitionValues());
      // non-partitioned table

      Path tablePath = new Path(table.getTTable().getSd().getLocation());
      FileSystem fs = tablePath.getFileSystem(context.getConfiguration());

      if (!MetaStoreUtils.isDirEmpty(fs,tablePath)){
        throw new HCatException(ErrorType.ERROR_NON_EMPTY_TABLE,
            table.getDbName() + "." + table.getTableName());
      }
    }
  }
View Full Code Here


   * @throws java.io.IOException
   */
  static List<String> getPartitionValueList(Table table, Map<String, String> valueMap) throws IOException {

    if (valueMap.size() != table.getPartitionKeys().size()) {
      throw new HCatException(ErrorType.ERROR_INVALID_PARTITION_VALUES,
        "Table "
          + table.getTableName() + " has " +
          table.getPartitionKeys().size() + " partition keys, got " +
          valueMap.size());
    }

    List<String> values = new ArrayList<String>();

    for (FieldSchema schema : table.getPartitionKeys()) {
      String value = valueMap.get(schema.getName().toLowerCase());

      if (value == null) {
        throw new HCatException(ErrorType.ERROR_MISSING_PARTITION_KEY,
          "Key " + schema.getName() + " of table " + table.getTableName());
      }

      values.add(value);
    }
View Full Code Here

    throws HCatException {
    List<String> dbNames = null;
    try {
      dbNames = hmsClient.getDatabases(pattern);
    } catch (MetaException exp) {
      throw new HCatException("MetaException while listing db names", exp);
    }
    return dbNames;
  }
View Full Code Here

      }
    } catch (NoSuchObjectException exp) {
      throw new ObjectNotFoundException(
        "NoSuchObjectException while fetching database", exp);
    } catch (MetaException exp) {
      throw new HCatException("MetaException while fetching database",
        exp);
    } catch (TException exp) {
      throw new ConnectionFailureException(
        "TException while fetching database", exp);
    }
View Full Code Here

  public void createDatabase(HCatCreateDBDesc dbInfo) throws HCatException {
    try {
      hmsClient.createDatabase(dbInfo.toHiveDb());
    } catch (AlreadyExistsException exp) {
      if (!dbInfo.getIfNotExists()) {
        throw new HCatException(
          "AlreadyExistsException while creating database", exp);
      }
    } catch (InvalidObjectException exp) {
      throw new HCatException(
        "InvalidObjectException while creating database", exp);
    } catch (MetaException exp) {
      throw new HCatException("MetaException while creating database",
        exp);
    } catch (TException exp) {
      throw new ConnectionFailureException(
        "TException while creating database", exp);
    }
View Full Code Here

      if (!ifExists) {
        throw new ObjectNotFoundException(
          "NoSuchObjectException while dropping db.", e);
      }
    } catch (InvalidOperationException e) {
      throw new HCatException(
        "InvalidOperationException while dropping db.", e);
    } catch (MetaException e) {
      throw new HCatException("MetaException while dropping db.", e);
    } catch (TException e) {
      throw new ConnectionFailureException("TException while dropping db.",
        e);
    }
  }
View Full Code Here

                        String tablePattern) throws HCatException {
    List<String> tableNames = null;
    try {
      tableNames = hmsClient.getTables(checkDB(dbName), tablePattern);
    } catch (MetaException e) {
      throw new HCatException(
        "MetaException while fetching table names.", e);
    }
    return tableNames;
  }
View Full Code Here

      Table hiveTable = hmsClient.getTable(checkDB(dbName), tableName);
      if (hiveTable != null) {
        table = new HCatTable(hiveTable);
      }
    } catch (MetaException e) {
      throw new HCatException("MetaException while fetching table.", e);
    } catch (NoSuchObjectException e) {
      throw new ObjectNotFoundException(
        "NoSuchObjectException while fetching table.", e);
    } catch (TException e) {
      throw new ConnectionFailureException(
View Full Code Here

    throws HCatException {
    try {
      hmsClient.createTable(createTableDesc.toHiveTable(hiveConfig));
    } catch (AlreadyExistsException e) {
      if (!createTableDesc.getIfNotExists()) {
        throw new HCatException(
          "AlreadyExistsException while creating table.", e);
      }
    } catch (InvalidObjectException e) {
      throw new HCatException(
        "InvalidObjectException while creating table.", e);
    } catch (MetaException e) {
      throw new HCatException("MetaException while creating table.", e);
    } catch (NoSuchObjectException e) {
      throw new ObjectNotFoundException(
        "NoSuchObjectException while creating table.", e);
    } catch (TException e) {
      throw new ConnectionFailureException(
        "TException while creating table.", e);
    } catch (IOException e) {
      throw new HCatException("IOException while creating hive conf.", e);
    }

  }
View Full Code Here

      Table table = hmsClient.getTable(dbName, tableName);
      table.getSd().setCols(HCatSchemaUtils.getFieldSchemas(columnSchema));
      hmsClient.alter_table(dbName, tableName, table);
    }
    catch (InvalidOperationException e) {
      throw new HCatException("InvalidOperationException while updating table schema.", e);
    }
    catch (MetaException e) {
      throw new HCatException("MetaException while updating table schema.", e);
    }
    catch (NoSuchObjectException e) {
      throw new ObjectNotFoundException(
          "NoSuchObjectException while updating table schema.", e);
    }
View Full Code Here

TOP

Related Classes of org.apache.hive.hcatalog.common.HCatException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.