{"record":{"id":"1d546b89695ac313","repo":"apache/iceberg","slug":"unsupported-strategy-strategy-only-binpack","errorCode":null,"errorMessage":"unsupported strategy: + strategy + . Only binpack or sort is supported","messagePattern":"unsupported strategy: \\+ strategy \\+ \\. Only binpack or sort is supported","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/procedures/RewriteDataFilesProcedure.java","lineNumber":204,"sourceCode":"                .flatMap(zOrder -> zOrder.refs().stream().map(NamedReference::name))\n                .toArray(String[]::new);\n        return action.zOrder(columnNames);\n      } else if (!sortOrderFields.isEmpty()) {\n        return action.sort(buildSortOrder(sortOrderFields, schema));\n      } else {\n        return action.sort();\n      }\n    }\n    if (strategy.equalsIgnoreCase(\"binpack\")) {\n      RewriteDataFilesSparkAction binPackAction = action.binPack();\n      if (sortOrderString != null) {\n        // calling below method to throw the error as user has set both binpack strategy and sort\n        // order\n        return binPackAction.sort(buildSortOrder(sortOrderFields, schema));\n      }\n      return binPackAction;\n    } else {\n      throw new IllegalArgumentException(\n          \"unsupported strategy: \" + strategy + \". Only binpack or sort is supported\");\n    }\n  }\n\n  private SortOrder buildSortOrder(\n      List<ExtendedParser.RawOrderField> rawOrderFields, Schema schema) {\n    SortOrder.Builder builder = SortOrder.builderFor(schema);\n    rawOrderFields.forEach(\n        rawField -> builder.sortBy(rawField.term(), rawField.direction(), rawField.nullOrder()));\n    return builder.build();\n  }\n\n  private InternalRow[] toOutputRows(RewriteDataFiles.Result result) {\n    int rewrittenDataFilesCount = result.rewrittenDataFilesCount();\n    long rewrittenBytesCount = result.rewrittenBytesCount();\n    int addedDataFilesCount = result.addedDataFilesCount();\n    int failedDataFilesCount = result.failedDataFilesCount();\n    int removedDeleteFilesCount = result.removedDeleteFilesCount();","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/procedures/RewriteDataFilesProcedure.java#L186-L222","documentation":"RewriteDataFilesProcedure accepts only the rewrite strategies 'binpack' or 'sort' for the strategy option. Any other string reaches checkAndApplyStrategy's final else and throws IllegalArgumentException listing the accepted values. This is input validation of the strategy enum-like argument.","triggerScenarios":"CALL iceberg.system.rewrite_data_files(table => 'db.t', strategy => 'zorder') or strategy => 'compact' or 'SORT' (case-sensitive) — any value outside binpack/sort.","commonSituations":"Assuming 'zorder' is a valid strategy value (Zorder is configured via sort options, not strategy); misspellings like 'binpack ' with trailing space or 'bin-pack'; copying options from other engines (e.g. 'auto').","solutions":["Use strategy => 'binpack' or strategy => 'sort' exactly (lowercase).","Remove the strategy option entirely to use the default.","For Z-order layout, use strategy => 'sort' with the z_order sort option instead of strategy => 'zorder'.","Trim/normalize the value before invoking the procedure programmatically."],"exampleFix":"-- before\nCALL iceberg.system.rewrite_data_files(table => 'db.t', strategy => 'zorder');\n-- after\nCALL iceberg.system.rewrite_data_files(table => 'db.t', strategy => 'sort', z_order => 'col1,col2');","handlingStrategy":"validation","validationCode":"if (!\"binpack\".equals(strategy) && !\"sort\".equals(strategy)) throw new IllegalArgumentException(\"strategy must be 'binpack' or 'sort', got: \" + strategy);","typeGuard":null,"tryCatchPattern":"try { rewriteDataFiles(..., strategy); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"unsupported strategy\")) { /* use binpack or sort */ } else throw e; }","preventionTips":["Use lowercase 'binpack' or 'sort' literally.","For Z-order, use strategy 'sort' plus the z_order option.","Trim user-supplied strategy strings before passing them."],"tags":["spark","compaction","invalid-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}