use of com.facebook.presto.verifier.framework.QueryStage.TEST_MAIN in project presto by prestodb.
the class TooManyOpenPartitionsFailureResolver method resolveQueryFailure.
@Override
public Optional<String> resolveQueryFailure(QueryStats controlQueryStats, QueryException queryException, Optional<QueryObjectBundle> test) {
if (!test.isPresent()) {
return Optional.empty();
}
return mapMatchingPrestoException(queryException, TEST_MAIN, ImmutableSet.of(HIVE_TOO_MANY_OPEN_PARTITIONS), e -> {
try {
ShowCreate showCreate = new ShowCreate(TABLE, test.get().getObjectName());
String showCreateResult = getOnlyElement(prestoAction.execute(showCreate, DESCRIBE, resultSet -> Optional.of(resultSet.getString(1))).getResults());
CreateTable createTable = (CreateTable) sqlParser.createStatement(showCreateResult, ParsingOptions.builder().setDecimalLiteralTreatment(AS_DOUBLE).build());
List<Property> bucketCountProperty = createTable.getProperties().stream().filter(property -> property.getName().getValue().equals(BUCKET_COUNT_PROPERTY)).collect(toImmutableList());
if (bucketCountProperty.size() != 1) {
return Optional.empty();
}
long bucketCount = ((LongLiteral) getOnlyElement(bucketCountProperty).getValue()).getValue();
int testClusterSize = this.testClusterSizeSupplier.get();
if (testClusterSize * maxBucketPerWriter < bucketCount) {
return Optional.of("Not enough workers on test cluster");
}
return Optional.empty();
} catch (Throwable t) {
log.warn(t, "Exception when resolving HIVE_TOO_MANY_OPEN_PARTITIONS");
return Optional.empty();
}
});
}
Aggregations