prestodb/presto · error · PrestoException

NOT_SUPPORTED

NOT_SUPPORTED

Error message

Invalid rewrite strategy: %s. Valid values are 'sort' or 'binpack'.

What it means

NOT_SUPPORTED thrown by parseStrategy when the strategy argument of rewrite_data_files cannot be parsed into a RewriteStrategy enum. Only 'sort' and 'binpack' are valid; any other string fails valueOf and produces this error listing the accepted values.

Source

Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/RewriteDataFilesProcedure.java:173

     * Parses the `strategy` procedure argument, defaulting to {@link RewriteStrategy#BINPACK} when it is not specified.
     *
     * @throws PrestoException if the value is not a recognized strategy
     */
    private static RewriteStrategy parseStrategy(Object[] procedureArgs)
    {
        if (procedureArgs.length <= STRATEGY_ARGUMENT_INDEX || procedureArgs[STRATEGY_ARGUMENT_INDEX] == null) {
            return RewriteStrategy.BINPACK;
        }

        Object strategyArgument = procedureArgs[STRATEGY_ARGUMENT_INDEX];
        String strategyStr = strategyArgument instanceof Slice ?
                ((Slice) strategyArgument).toStringUtf8() :
                strategyArgument.toString();
        try {
            return RewriteStrategy.valueOf(strategyStr.trim().toUpperCase(Locale.ENGLISH));
        }
        catch (IllegalArgumentException e) {
            throw new PrestoException(NOT_SUPPORTED,
                    format("Invalid rewrite strategy: %s. Valid values are 'sort' or 'binpack'.", strategyStr));
        }
    }

    private static Map<String, String> extractAndValidateOptions(Object[] procedureArgs)
    {
        Map<String, String> options = ImmutableMap.of();
        if (procedureArgs.length > OPTIONS_ARGUMENT_INDEX && procedureArgs[OPTIONS_ARGUMENT_INDEX] instanceof Map) {
            options = (Map<String, String>) procedureArgs[OPTIONS_ARGUMENT_INDEX];

            // Validate options if present using utility methods
            parseMinInputFiles(options);
            parseMinFileSize(options);
            parseMaxFileSize(options);
            parseRewriteAll(options);
        }
        return options;
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Change the strategy argument to 'sort' or 'binpack' (case-insensitive)
  2. If aiming for z-order compaction, use the engine/documentation version that supports it, or use the table's sort order with strategy='sort'
  3. Check spelling/hyphenation: 'binpack', not 'bin-pack'

Example fix

// before
CALL system.rewrite_data_files('s', 't', strategy => 'zorder')
// after
CALL system.rewrite_data_files('s', 't', strategy => 'binpack')
Defensive patterns

Strategy: validation

Validate before calling

// Validate the strategy value client-side before calling the procedure
Set<String> valid = Set.of("sort", "binpack");
if (strategy == null || !valid.contains(strategy.trim().toLowerCase(Locale.ROOT))) {
    throw new IllegalArgumentException("strategy must be 'sort' or 'binpack'");
}

Prevention

When it happens

Trigger: Calling the rewrite_data_files procedure with procedure argument strategy set to a string other than 'sort' or 'binpack' (case-insensitive after trim), e.g. 'zorder', 'compact', or a misspelled value.

Common situations: Copy-pasted SQL from docs of a different engine that supports more strategies (e.g. zorder in other Iceberg runtimes); typo like 'bin-pack' or 'BinPack' with punctuation; passing NULL/garbage from a script.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/de831521bd5e55ab. Report an issue: GitHub.