Package org.apache.hive.hcatalog.common

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


    try {
      // TODO: Verify that this works for systems using UGI.doAs() (e.g. Oozie).
      newTable.setOwner(owner == null? getConf().getUser() : owner);
    }
    catch (Exception exception) {
      throw new HCatException("Unable to determine owner of table (" + dbName + "." + tableName
          + ") from HiveConf.");
    }
    return newTable;
  }
View Full Code Here


        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

    }
  }

  public void append(final HCatFieldSchema hfs) throws HCatException {
    if (hfs == null)
      throw new HCatException("Attempt to append null HCatFieldSchema in HCatSchema.");

    String fieldName = normalizeName(hfs.getName());
    if (fieldPositionMap.containsKey(fieldName))
      throw new HCatException("Attempt to append HCatFieldSchema with already " +
        "existing name: " + fieldName + ".");

    this.fieldSchemas.add(hfs);
    this.fieldNames.add(fieldName);
    this.fieldPositionMap.put(fieldName, this.size() - 1);
View Full Code Here

    }
  }

  public void remove(final HCatFieldSchema hcatFieldSchema) throws HCatException {
    if (!fieldSchemas.contains(hcatFieldSchema)) {
      throw new HCatException("Attempt to delete a non-existent column from HCat Schema: " + hcatFieldSchema);
    }    
    fieldSchemas.remove(hcatFieldSchema);
    // Re-align the positionMap by -1 for the columns appearing after hcatFieldSchema.
    String fieldName = normalizeName(hcatFieldSchema.getName());
    reAlignPositionMap(fieldPositionMap.get(fieldName)+1, -1);
View Full Code Here

      Class<? extends HCatClient> clientClass = Class.forName(className,
        true, Utilities.getSessionSpecifiedClassLoader()).asSubclass(
          HCatClient.class);
      client = (HCatClient) clientClass.newInstance();
    } catch (ClassNotFoundException e) {
      throw new HCatException(
        "ClassNotFoundException while creating client class.", e);
    } catch (InstantiationException e) {
      throw new HCatException(
        "InstantiationException while creating client class.", e);
    } catch (IllegalAccessException e) {
      throw new HCatException(
        "IllegalAccessException while creating client class.", e);
    }
    if (client != null) {
      client.initialize(conf);
    }
View Full Code Here

  }

  private static void assertTypeInCategory(Type type, Category category, String fieldName) throws HCatException {
    Category typeCategory = Category.fromType(type);
    if (typeCategory != category) {
      throw new HCatException("Type category mismatch. Expected " + category + " but type " + type + " in category " + typeCategory + " (field " + fieldName + ")");
    }
  }
View Full Code Here

  }

  private static void assertTypeNotInCategory(Type type, Category category) throws HCatException {
    Category typeCategory = Category.fromType(type);
    if (typeCategory == category) {
      throw new HCatException("Type category mismatch. Expected type " + type + " not in category " + category + " but was so.");
    }
  }
View Full Code Here

    this.createTime = partition.getCreateTime();
    this.lastAccessTime = partition.getLastAccessTime();
    this.parameters = partition.getParameters();
    this.values = partition.getValues();
    if (hcatTable != null && partition.getValuesSize() != hcatTable.getPartCols().size()) {
      throw new HCatException("Mismatched number of partition columns between table:" + hcatTable.getDbName() + "." + hcatTable.getTableName()
                              + " and partition " + partition.getValues());
    }

    this.sd = partition.getSd();
    this.columns = getColumns(this.sd);
View Full Code Here

    this.createTime = (int)(System.currentTimeMillis()/1000);
    this.lastAccessTime = -1;
    this.values = new ArrayList<String>(hcatTable.getPartCols().size());
    for (HCatFieldSchema partField : hcatTable.getPartCols()) {
      if (!partitionKeyValues.containsKey(partField.getName())) {
        throw new HCatException("Missing value for partition-key \'" + partField.getName()
            + "\' in table: " + hcatTable.getDbName() + "." + hcatTable.getTableName());
      }
      else {
        values.add(partitionKeyValues.get(partField.getName()));
      }
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.