@Override public void addPartitions(String databaseName, String tableName, List<PartitionWithStatistics> partitions) { try { List<List<PartitionWithStatistics>> batchedPartitions = Lists.partition(partitions, BATCH_CREATE_PARTITION_MAX_PAGE_SIZE); List<Future<BatchCreatePartitionResult>> futures = new ArrayList<>(); for (List<PartitionWithStatistics> partitionBatch : batchedPartitions) { List<PartitionInput> partitionInputs = partitionBatch.stream().map(GlueInputConverter::convertPartition).collect(toList()); futures.add(glueClient.batchCreatePartitionAsync(new BatchCreatePartitionRequest() .withDatabaseName(databaseName) .withTableName(tableName) .withPartitionInputList(partitionInputs))); } for (Future<BatchCreatePartitionResult> future : futures) { BatchCreatePartitionResult result = future.get(); propagatePartitionErrorToPrestoException(databaseName, tableName, result.getErrors()); } } catch (AmazonServiceException | InterruptedException | ExecutionException e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } throw new PrestoException(HIVE_METASTORE_ERROR, e); } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getCatalogId() == null) ? 0 : getCatalogId().hashCode()); hashCode = prime * hashCode + ((getDatabaseName() == null) ? 0 : getDatabaseName().hashCode()); hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); hashCode = prime * hashCode + ((getPartitionInputList() == null) ? 0 : getPartitionInputList().hashCode()); return hashCode; }
/** * <p> * The ID of the catalog in which the partion is to be created. Currently, this should be the AWS account ID. * </p> * * @param catalogId * The ID of the catalog in which the partion is to be created. Currently, this should be the AWS account ID. * @return Returns a reference to this object so that method calls can be chained together. */ public BatchCreatePartitionRequest withCatalogId(String catalogId) { setCatalogId(catalogId); return this; }
/** * <p> * The name of the metadata database in which the partition is to be created. * </p> * * @param databaseName * The name of the metadata database in which the partition is to be created. * @return Returns a reference to this object so that method calls can be chained together. */ public BatchCreatePartitionRequest withDatabaseName(String databaseName) { setDatabaseName(databaseName); return this; }
/** * <p> * The name of the metadata database in which the partition is to be created. * </p> * * @param databaseName * The name of the metadata database in which the partition is to be created. * @return Returns a reference to this object so that method calls can be chained together. */ public BatchCreatePartitionRequest withDatabaseName(String databaseName) { setDatabaseName(databaseName); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof BatchCreatePartitionRequest == false) return false; BatchCreatePartitionRequest other = (BatchCreatePartitionRequest) obj; if (other.getCatalogId() == null ^ this.getCatalogId() == null) return false; if (other.getCatalogId() != null && other.getCatalogId().equals(this.getCatalogId()) == false) return false; if (other.getDatabaseName() == null ^ this.getDatabaseName() == null) return false; if (other.getDatabaseName() != null && other.getDatabaseName().equals(this.getDatabaseName()) == false) return false; if (other.getTableName() == null ^ this.getTableName() == null) return false; if (other.getTableName() != null && other.getTableName().equals(this.getTableName()) == false) return false; if (other.getPartitionInputList() == null ^ this.getPartitionInputList() == null) return false; if (other.getPartitionInputList() != null && other.getPartitionInputList().equals(this.getPartitionInputList()) == false) return false; return true; }
@Override public void addPartitions(String databaseName, String tableName, List<PartitionWithStatistics> partitions) { try { List<List<PartitionWithStatistics>> batchedPartitions = Lists.partition(partitions, BATCH_CREATE_PARTITION_MAX_PAGE_SIZE); List<Future<BatchCreatePartitionResult>> futures = new ArrayList<>(); for (List<PartitionWithStatistics> partitionBatch : batchedPartitions) { List<PartitionInput> partitionInputs = partitionBatch.stream().map(GlueInputConverter::convertPartition).collect(toList()); futures.add(glueClient.batchCreatePartitionAsync(new BatchCreatePartitionRequest() .withDatabaseName(databaseName) .withTableName(tableName) .withPartitionInputList(partitionInputs))); } for (Future<BatchCreatePartitionResult> future : futures) { BatchCreatePartitionResult result = future.get(); propagatePartitionErrorToPrestoException(databaseName, tableName, result.getErrors()); } } catch (AmazonServiceException | InterruptedException | ExecutionException e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } throw new PrestoException(HIVE_METASTORE_ERROR, e); } }
/** * <p> * The ID of the catalog in which the partion is to be created. Currently, this should be the AWS account ID. * </p> * * @param catalogId * The ID of the catalog in which the partion is to be created. Currently, this should be the AWS account ID. * @return Returns a reference to this object so that method calls can be chained together. */ public BatchCreatePartitionRequest withCatalogId(String catalogId) { setCatalogId(catalogId); return this; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getCatalogId() != null) sb.append("CatalogId: ").append(getCatalogId()).append(","); if (getDatabaseName() != null) sb.append("DatabaseName: ").append(getDatabaseName()).append(","); if (getTableName() != null) sb.append("TableName: ").append(getTableName()).append(","); if (getPartitionInputList() != null) sb.append("PartitionInputList: ").append(getPartitionInputList()); sb.append("}"); return sb.toString(); }
/** * Marshall the given parameter object. */ public void marshall(BatchCreatePartitionRequest batchCreatePartitionRequest, ProtocolMarshaller protocolMarshaller) { if (batchCreatePartitionRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(batchCreatePartitionRequest.getCatalogId(), CATALOGID_BINDING); protocolMarshaller.marshall(batchCreatePartitionRequest.getDatabaseName(), DATABASENAME_BINDING); protocolMarshaller.marshall(batchCreatePartitionRequest.getTableName(), TABLENAME_BINDING); protocolMarshaller.marshall(batchCreatePartitionRequest.getPartitionInputList(), PARTITIONINPUTLIST_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getCatalogId() == null) ? 0 : getCatalogId().hashCode()); hashCode = prime * hashCode + ((getDatabaseName() == null) ? 0 : getDatabaseName().hashCode()); hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); hashCode = prime * hashCode + ((getPartitionInputList() == null) ? 0 : getPartitionInputList().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof BatchCreatePartitionRequest == false) return false; BatchCreatePartitionRequest other = (BatchCreatePartitionRequest) obj; if (other.getCatalogId() == null ^ this.getCatalogId() == null) return false; if (other.getCatalogId() != null && other.getCatalogId().equals(this.getCatalogId()) == false) return false; if (other.getDatabaseName() == null ^ this.getDatabaseName() == null) return false; if (other.getDatabaseName() != null && other.getDatabaseName().equals(this.getDatabaseName()) == false) return false; if (other.getTableName() == null ^ this.getTableName() == null) return false; if (other.getTableName() != null && other.getTableName().equals(this.getTableName()) == false) return false; if (other.getPartitionInputList() == null ^ this.getPartitionInputList() == null) return false; if (other.getPartitionInputList() != null && other.getPartitionInputList().equals(this.getPartitionInputList()) == false) return false; return true; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getCatalogId() != null) sb.append("CatalogId: ").append(getCatalogId()).append(","); if (getDatabaseName() != null) sb.append("DatabaseName: ").append(getDatabaseName()).append(","); if (getTableName() != null) sb.append("TableName: ").append(getTableName()).append(","); if (getPartitionInputList() != null) sb.append("PartitionInputList: ").append(getPartitionInputList()); sb.append("}"); return sb.toString(); }
/** * Marshall the given parameter object. */ public void marshall(BatchCreatePartitionRequest batchCreatePartitionRequest, ProtocolMarshaller protocolMarshaller) { if (batchCreatePartitionRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(batchCreatePartitionRequest.getCatalogId(), CATALOGID_BINDING); protocolMarshaller.marshall(batchCreatePartitionRequest.getDatabaseName(), DATABASENAME_BINDING); protocolMarshaller.marshall(batchCreatePartitionRequest.getTableName(), TABLENAME_BINDING); protocolMarshaller.marshall(batchCreatePartitionRequest.getPartitionInputList(), PARTITIONINPUTLIST_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }