Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions presto-verifier/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@
</exclusions>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-hive</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-hive-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,23 @@ private FailureResolverUtil() {}
public static <T> Optional<T> mapMatchingPrestoException(
QueryException queryException,
QueryStage queryStage,
Set<ErrorCodeSupplier> errorCodes,
Set<ErrorCodeSupplier> errorCodeSuppliers,
Function<PrestoQueryException, Optional<T>> mapper)
{
if (queryException.getQueryStage() != queryStage || !(queryException instanceof PrestoQueryException)) {
return Optional.empty();
}
PrestoQueryException prestoException = (PrestoQueryException) queryException;
if (!prestoException.getErrorCode().isPresent() || !errorCodes.contains(prestoException.getErrorCode().get())) {
if (!prestoException.getErrorCode().isPresent()) {
return Optional.empty();
}
return mapper.apply(prestoException);

int code = prestoException.getErrorCode().get().toErrorCode().getCode();
for (ErrorCodeSupplier supplier : errorCodeSuppliers) {
if (supplier.toErrorCode().getCode() == code) {
return mapper.apply(prestoException);
}
}
return Optional.empty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
package com.facebook.presto.verifier.resolver;

import com.facebook.airlift.log.Logger;
import com.facebook.presto.common.ErrorCode;
import com.facebook.presto.common.ErrorType;
import com.facebook.presto.jdbc.QueryStats;
import com.facebook.presto.spi.ErrorCodeSupplier;
import com.facebook.presto.sql.parser.ParsingOptions;
import com.facebook.presto.sql.parser.SqlParser;
import com.facebook.presto.sql.tree.CreateTable;
Expand All @@ -34,8 +37,6 @@
import java.util.Optional;
import java.util.function.Supplier;

import static com.facebook.presto.hive.HiveErrorCode.HIVE_TOO_MANY_OPEN_PARTITIONS;
import static com.facebook.presto.hive.HiveTableProperties.BUCKET_COUNT_PROPERTY;
import static com.facebook.presto.sql.parser.ParsingOptions.DecimalLiteralTreatment.AS_DOUBLE;
import static com.facebook.presto.sql.tree.ShowCreate.Type.TABLE;
import static com.facebook.presto.verifier.framework.QueryStage.DESCRIBE;
Expand Down Expand Up @@ -79,14 +80,24 @@ public Optional<String> resolveQueryFailure(QueryStats controlQueryStats, QueryE
return Optional.empty();
}

return mapMatchingPrestoException(queryException, TEST_MAIN, ImmutableSet.of(HIVE_TOO_MANY_OPEN_PARTITIONS),
// Decouple from com.facebook.presto.hive.HiveErrorCode.HIVE_TOO_MANY_OPEN_PARTITIONS
ErrorCodeSupplier errorCodeSupplier = new ErrorCodeSupplier() {
@Override
public ErrorCode toErrorCode()
{
int errorCodeMask = 0x0100_0000;
return new ErrorCode(21 + errorCodeMask, "HIVE_TOO_MANY_OPEN_PARTITIONS", ErrorType.USER_ERROR);
}
};

return mapMatchingPrestoException(queryException, TEST_MAIN, ImmutableSet.of(errorCodeSupplier),
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))
.filter(property -> property.getName().getValue().equals("bucket_count"))
.collect(toImmutableList());
if (bucketCountProperty.size() != 1) {
return Optional.empty();
Expand Down