/** * Gets the database name. * * @return the database name */ @Deprecated // @deprecated in favour of {@link HCatTable.#getDbName()}. To be removed in Hive 0.16. public String getDatabaseName() { return this.hcatTable.getDbName(); }
public HCatPartition hcatTable(HCatTable hcatTable) { this.hcatTable = hcatTable; this.tableName = hcatTable.getTableName(); this.dbName = hcatTable.getDbName(); return this; }
HCatPartition getHCatPartition(HCatTable hcatTable) throws HCatException { assert hcatPartition == null : "hcatPartition should have been null at this point."; assert dbName.equalsIgnoreCase(hcatTable.getDbName()) : "DB names don't match."; assert tableName.equalsIgnoreCase(hcatTable.getTableName()) : "Table names don't match."; return new HCatPartition(hcatTable, partitionKeyValues, location); }
private void assert_invariant() throws HCatException { if (hcatTable != null) { if (!hcatTable.getDbName().equalsIgnoreCase(partitionSpecProxy.getDbName())) { String errorMessage = "Invalid HCatPartitionSpec instance: Table's DBName (" + hcatTable.getDbName() + ") " + "doesn't match PartitionSpec (" + partitionSpecProxy.getDbName() + ")"; assert false : errorMessage; throw new HCatException(errorMessage); } if (!hcatTable.getTableName().equalsIgnoreCase(partitionSpecProxy.getTableName())) { String errorMessage = "Invalid HCatPartitionSpec instance: Table's TableName (" + hcatTable.getTableName() + ") " + "doesn't match PartitionSpec (" + partitionSpecProxy.getTableName() + ")"; assert false : errorMessage; throw new HCatException(errorMessage); } } }
/** * Setter for partition key-values. */ public HCatPartition setPartitionKeyValues(Map<String, String> partitionKeyValues) throws HCatException { 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())); // Keep partKeyValMap in synch as well. } } return this; }
public HCatPartition(HCatTable hcatTable, Map<String, String> partitionKeyValues, String location) throws HCatException { this.hcatTable = hcatTable; this.tableName = hcatTable.getTableName(); this.dbName = hcatTable.getDbName(); this.sd = new StorageDescriptor(hcatTable.getSd()); this.sd.setLocation(location); this.columns = getColumns(this.sd); 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())); } } }
public HCatPartition(HCatPartition rhs, Map<String, String> partitionKeyValues, String location) throws HCatException { this.hcatTable = rhs.hcatTable; this.tableName = rhs.tableName; this.dbName = rhs.dbName; this.sd = new StorageDescriptor(rhs.sd); this.sd.setLocation(location); this.columns = getColumns(this.sd); 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())); } } }
@Override public List<HCatPartition> deserializePartitions(List<String> hcatPartitionStringReps) throws HCatException { List<HCatPartition> partitions = new ArrayList<HCatPartition>(hcatPartitionStringReps.size()); MetadataSerializer deserializer = MetadataSerializer.get(); HCatTable table = null; for (String partString : hcatPartitionStringReps) { HCatPartition partition; if (table == null) { partition = deserializePartition(partString); table = partition.hcatTable(); } else { partition = deserializer.deserializePartition(partString); if (partition.getDatabaseName().equals(table.getDbName()) && partition.getTableName().equals(table.getTableName())) { partition.hcatTable(table); } else { throw new HCatException("All partitions are not of the same table: " + table.getDbName() + "." + table.getTableName()); } } partitions.add(partition); } return partitions; }
@Override public List<HCatPartition> listPartitionsByFilter(String dbName, String tblName, String filter) throws HCatException { List<HCatPartition> hcatPtns = new ArrayList<HCatPartition>(); try { HCatTable table = getTable(dbName, tblName); List<Partition> hivePtns = hmsClient.listPartitionsByFilter( table.getDbName(), table.getTableName(), filter, (short) -1); for (Partition ptn : hivePtns) { hcatPtns.add(new HCatPartition(table, ptn)); } } catch (MetaException e) { throw new HCatException("MetaException while fetching partitions.", e); } catch (NoSuchObjectException e) { throw new ObjectNotFoundException( "NoSuchObjectException while fetching partitions.", e); } catch (TException e) { throw new ConnectionFailureException( "TException while fetching partitions.", e); } return hcatPtns; }
Partition toHivePartition() throws HCatException { Partition hivePtn = new Partition(); hivePtn.setDbName(dbName); hivePtn.setTableName(tableName); hivePtn.setValues(values); hivePtn.setParameters(parameters); if (sd.getLocation() == null) { LOG.warn("Partition location is not set! Attempting to construct default partition location."); try { String partName = Warehouse.makePartName(HCatSchemaUtils.getFieldSchemas(hcatTable.getPartCols()), values); sd.setLocation(new Path(hcatTable.getSd().getLocation(), partName).toString()); } catch(MetaException exception) { throw new HCatException("Could not construct default partition-path for " + hcatTable.getDbName() + "." + hcatTable.getTableName() + "[" + values + "]"); } } hivePtn.setSd(sd); hivePtn.setCreateTime((int) (System.currentTimeMillis() / 1000)); hivePtn.setLastAccessTimeIsSet(false); return hivePtn; }
HCatPartition(HCatTable hcatTable, Partition partition) throws HCatException { this.hcatTable = hcatTable; this.tableName = partition.getTableName(); this.dbName = partition.getDbName(); 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); }
/** * Gets the database name. * * @return the database name */ @Deprecated // @deprecated in favour of {@link HCatTable.#getDbName()}. To be removed in Hive 0.16. public String getDatabaseName() { return this.hcatTable.getDbName(); }
/** * Gets the database name. * * @return the database name */ @Deprecated // @deprecated in favour of {@link HCatTable.#getDbName()}. To be removed in Hive 0.16. public String getDatabaseName() { return this.hcatTable.getDbName(); }
/** * Gets the database name. * * @return the database name */ @Deprecated // @deprecated in favour of {@link HCatTable.#getDbName()}. To be removed in Hive 0.16. public String getDatabaseName() { return this.hcatTable.getDbName(); }
public HCatPartition hcatTable(HCatTable hcatTable) { this.hcatTable = hcatTable; this.tableName = hcatTable.getTableName(); this.dbName = hcatTable.getDbName(); return this; }
public HCatPartition hcatTable(HCatTable hcatTable) { this.hcatTable = hcatTable; this.tableName = hcatTable.getTableName(); this.dbName = hcatTable.getDbName(); return this; }
public HCatPartition hcatTable(HCatTable hcatTable) { this.hcatTable = hcatTable; this.tableName = hcatTable.getTableName(); this.dbName = hcatTable.getDbName(); return this; }
HCatPartition getHCatPartition(HCatTable hcatTable) throws HCatException { assert hcatPartition == null : "hcatPartition should have been null at this point."; assert dbName.equalsIgnoreCase(hcatTable.getDbName()) : "DB names don't match."; assert tableName.equalsIgnoreCase(hcatTable.getTableName()) : "Table names don't match."; return new HCatPartition(hcatTable, partitionKeyValues, location); }
HCatPartition getHCatPartition(HCatTable hcatTable) throws HCatException { assert hcatPartition == null : "hcatPartition should have been null at this point."; assert dbName.equalsIgnoreCase(hcatTable.getDbName()) : "DB names don't match."; assert tableName.equalsIgnoreCase(hcatTable.getTableName()) : "Table names don't match."; return new HCatPartition(hcatTable, partitionKeyValues, location); }
HCatPartition getHCatPartition(HCatTable hcatTable) throws HCatException { assert hcatPartition == null : "hcatPartition should have been null at this point."; assert dbName.equalsIgnoreCase(hcatTable.getDbName()) : "DB names don't match."; assert tableName.equalsIgnoreCase(hcatTable.getTableName()) : "Table names don't match."; return new HCatPartition(hcatTable, partitionKeyValues, location); }