@Override
    public Optional<String> resolveQueryFailure(QueryStats controlQueryStats, QueryException queryException, Optional<QueryObjectBundle> test)
    {
        if (!test.isPresent()) {
            return Optional.empty();
        }

        // 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"))
                                .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();
                    }
                });
    }
@Test
    public void testUnresolvedSufficientWorker()
    {
        createTable.set(format("CREATE TABLE %s (x varchar, ds varchar) WITH (partitioned_by = ARRAY[\"ds\"], bucket_count = 100)", TABLE_NAME));
        getFailureResolver().resolveQueryFailure(CONTROL_QUERY_STATS, HIVE_TOO_MANY_OPEN_PARTITIONS_EXCEPTION, Optional.of(TEST_BUNDLE));
        assertFalse(getFailureResolver().resolveQueryFailure(CONTROL_QUERY_STATS, HIVE_TOO_MANY_OPEN_PARTITIONS_EXCEPTION, Optional.of(TEST_BUNDLE)).isPresent());
    }