/** * {@inheritDoc} */ @Override public String getNameFromPartVals(final TableDto tableDto, final List<String> partVals) { final List<String> partitionKeys = tableDto.getPartition_keys(); if (partitionKeys.size() != partVals.size()) { throw new IllegalArgumentException("Not the same number of partition columns and partition values"); } return FileUtils.makePartName(partitionKeys, partVals, ""); }
/** * {@inheritDoc} */ @Override public String getNameFromPartVals(final TableDto tableDto, final List<String> partVals) { final List<String> partitionKeys = tableDto.getPartition_keys(); if (partitionKeys.size() != partVals.size()) { throw new IllegalArgumentException("Not the same number of partition columns and partition values"); } return FileUtils.makePartName(partitionKeys, partVals, ""); }
@Override public String getNameFromPartVals(final TableDto tableDto, final List<String> partVals) { final List<String> partitionKeys = tableDto.getPartition_keys(); if (partitionKeys.size() != partVals.size()) { throw new IllegalArgumentException("Not the same number of partition columns and partition values"); } final StringBuilder builder = new StringBuilder(); for (int i = 0; i < partitionKeys.size(); i++) { if (builder.length() > 0) { builder.append('/'); } builder.append(partitionKeys.get(i)); builder.append('='); builder.append(partVals.get(i)); } return builder.toString(); }
@Override public List<String> getPartValsFromName(final TableDto tableDto, final String partName) { // Unescape the partition name LinkedHashMap<String, String> hm = null; try { hm = Warehouse.makeSpecFromName(partName); } catch (MetaException e) { throw new IllegalArgumentException("Invalid partition name", e); } final List<String> partVals = Lists.newArrayList(); for (String key : tableDto.getPartition_keys()) { final String val = hm.get(key); if (val == null) { throw new IllegalArgumentException("Invalid partition name - missing " + key); } partVals.add(val); } return partVals; }
partitionKeys = tableDto.getPartition_keys();
partitionKeys = tableDto.getPartition_keys();
String partition_values_to_partition_filter(final TableDto tableDto, final List<String> partVals) throws MetaException { if (partVals.size() > tableDto.getPartition_keys().size()) { throw new MetaException("Too many partition values for " + tableDto.getName());
String partition_values_to_partition_filter(final TableDto tableDto, final List<String> partVals) throws MetaException { if (partVals.size() > tableDto.getPartition_keys().size()) { throw new MetaException("Too many partition values for " + tableDto.getName());
private List<Partition> addPartitionsCore(final String dbName, final String tblName, final List<Partition> parts, final boolean ifNotExists) throws TException { log.debug("Ignoring {} since metacat save partitions will do an update if it already exists", ifNotExists); final TableDto tableDto = v1.getTable(catalogName, dbName, tblName, true, false, false); final List<String> partitionKeys = tableDto.getPartition_keys(); if (partitionKeys == null || partitionKeys.isEmpty()) { throw new MetaException("Unable to add partition to unpartitioned table: " + tableDto.getName()); } final PartitionsSaveRequestDto partitionsSaveRequestDto = new PartitionsSaveRequestDto(); final List<PartitionDto> converted = Lists.newArrayListWithCapacity(parts.size()); for (Partition partition : parts) { converted.add(hiveConverters.hiveToMetacatPartition(tableDto, partition)); } partitionsSaveRequestDto.setPartitions(converted); partV1.savePartitions(catalogName, dbName, tblName, partitionsSaveRequestDto); return parts; }
private List<Partition> addPartitionsCore(final String dbName, final String tblName, final List<Partition> parts, final boolean ifNotExists) throws TException { log.debug("Ignoring {} since metacat save partitions will do an update if it already exists", ifNotExists); final TableDto tableDto = v1.getTable(catalogName, dbName, tblName, true, false, false); final List<String> partitionKeys = tableDto.getPartition_keys(); if (partitionKeys == null || partitionKeys.isEmpty()) { throw new MetaException("Unable to add partition to unpartitioned table: " + tableDto.getName()); } final PartitionsSaveRequestDto partitionsSaveRequestDto = new PartitionsSaveRequestDto(); final List<PartitionDto> converted = Lists.newArrayListWithCapacity(parts.size()); for (Partition partition : parts) { converted.add(hiveConverters.hiveToMetacatPartition(tableDto, partition)); } partitionsSaveRequestDto.setPartitions(converted); partV1.savePartitions(catalogName, dbName, tblName, partitionsSaveRequestDto); return parts; }
/** * {@inheritDoc} */ @Override public TableDto copy(final TableDto tableDto, final QualifiedName targetName) { final QualifiedName databaseName = QualifiedName.ofDatabase(targetName.getCatalogName(), targetName.getDatabaseName()); if (!databaseService.exists(databaseName)) { final DatabaseDto databaseDto = new DatabaseDto(); databaseDto.setName(databaseName); databaseService.create(databaseName, databaseDto); } final TableDto targetTableDto = new TableDto(); targetTableDto.setName(targetName); targetTableDto.setFields(tableDto.getFields()); targetTableDto.setPartition_keys(tableDto.getPartition_keys()); final StorageDto storageDto = tableDto.getSerde(); if (storageDto != null) { final StorageDto targetStorageDto = new StorageDto(); targetStorageDto.setInputFormat(storageDto.getInputFormat()); targetStorageDto.setOwner(storageDto.getOwner()); targetStorageDto.setOutputFormat(storageDto.getOutputFormat()); targetStorageDto.setParameters(storageDto.getParameters()); targetStorageDto.setUri(storageDto.getUri()); targetStorageDto.setSerializationLib(storageDto.getSerializationLib()); targetTableDto.setSerde(targetStorageDto); } create(targetName, targetTableDto); return targetTableDto; }