/** * Returns the default partition path of a table within a given database and partition key value * pairs. It uses the database location and appends it the table name and the partition key,value * pairs to create the Path for the partition directory * * @param db - parent database which is used to get the base location of the partition directory * @param tableName - table name for the partitions * @param pm - Partition key value pairs * @return * @throws MetaException */ public Path getDefaultPartitionPath(Database db, Table table, Map<String, String> pm) throws MetaException { return getPartitionPath(getDefaultTablePath(db, table), pm); }
@Override public Path getPathForPartition(List<String> partitionValues) throws WorkerException { if (partitionValues.size() != partitionColumns.size()) { throw new IllegalArgumentException("Incorrect number of partition values. columns=" + partitionColumns + ",values=" + partitionValues); } if (partitionColumns.isEmpty()) { return tablePath; } for (int columnIndex = 0; columnIndex < partitionValues.size(); columnIndex++) { String partitionColumn = partitionColumns.get(columnIndex); String partitionValue = partitionValues.get(columnIndex); partitions.put(partitionColumn, partitionValue); } try { return warehouse.getPartitionPath(tablePath, partitions); } catch (MetaException e) { throw new WorkerException("Unable to determine partition path. tablePath=" + tablePath + ",partition=" + partitionValues, e); } }
/** * Given a database, a table and the partition key value pairs this method returns the Path object * corresponding to the partition key value pairs. It uses the table location if available else * uses the database location for constructing the path corresponding to the partition key-value * pairs * * @param db - Parent database of the given table * @param table - Table for which the partition key-values are given * @param vals - List of values for the partition keys * @return Path corresponding to the partition key-value pairs * @throws MetaException */ public Path getPartitionPath(Database db, Table table, List<String> vals) throws MetaException { List<FieldSchema> partKeys = table.getPartitionKeys(); if (partKeys == null || (partKeys.size() != vals.size())) { throw new MetaException("Invalid number of partition keys found for " + table.getTableName()); } Map<String, String> pm = new LinkedHashMap<>(vals.size()); int i = 0; for (FieldSchema key : partKeys) { pm.put(key.getName(), vals.get(i)); i++; } if (table.getSd().getLocation() != null) { return getPartitionPath(getDnsPath(new Path(table.getSd().getLocation())), pm); } else { return getDefaultPartitionPath(db, table, pm); } }
Path newPartPath = wh.getPartitionPath(newTablePath, partSpec); getHiveUpdater().updatePartitionLocation(dbName, tableObj, partName, partObj, newPartPath);
destPath = wh.getPartitionPath(db, tbl, new_part.getValues()); destPath = constructRenamedPath(destPath, new Path(new_part.getSd().getLocation())); } catch (NoSuchObjectException e) {
/** * Returns the default partition path of a table within a given database and partition key value * pairs. It uses the database location and appends it the table name and the partition key,value * pairs to create the Path for the partition directory * * @param db - parent database which is used to get the base location of the partition directory * @param tableName - table name for the partitions * @param pm - Partition key value pairs * @return * @throws MetaException */ public Path getDefaultPartitionPath(Database db, Table table, Map<String, String> pm) throws MetaException { return getPartitionPath(getDefaultTablePath(db, table), pm); }
/** * Given a database, a table and the partition key value pairs this method returns the Path object * corresponding to the partition key value pairs. It uses the table location if available else * uses the database location for constructing the path corresponding to the partition key-value * pairs * * @param db - Parent database of the given table * @param table - Table for which the partition key-values are given * @param vals - List of values for the partition keys * @return Path corresponding to the partition key-value pairs * @throws MetaException */ public Path getPartitionPath(Database db, Table table, List<String> vals) throws MetaException { List<FieldSchema> partKeys = table.getPartitionKeys(); if (partKeys == null || (partKeys.size() != vals.size())) { throw new MetaException("Invalid number of partition keys found for " + table.getTableName()); } Map<String, String> pm = new LinkedHashMap<>(vals.size()); int i = 0; for (FieldSchema key : partKeys) { pm.put(key.getName(), vals.get(i)); i++; } if (table.getSd().getLocation() != null) { return getPartitionPath(getDnsPath(new Path(table.getSd().getLocation())), pm); } else { return getDefaultPartitionPath(db, table, pm); } }
destPath = wh.getPartitionPath(db, tbl, new_part.getValues()); destPath = constructRenamedPath(destPath, new Path(new_part.getSd().getLocation())); } catch (NoSuchObjectException e) {