{"record":{"id":"ebd68c58d443bb4a","repo":"apache/iceberg","slug":"transform-is-not-supported-transform-ebd68c","errorCode":null,"errorMessage":"Transform is not supported: <transform>","messagePattern":"Transform is not supported: <transform>","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java","lineNumber":413,"sourceCode":"        case \"hour\":\n        case \"hours\":\n          return org.apache.iceberg.expressions.Expressions.hour(colName);\n        case \"truncate\":\n          return org.apache.iceberg.expressions.Expressions.truncate(colName, findWidth(transform));\n        case \"zorder\":\n          return new Zorder(\n              Stream.of(transform.references())\n                  .map(ref -> DOT.join(ref.fieldNames()))\n                  .map(org.apache.iceberg.expressions.Expressions::ref)\n                  .collect(Collectors.toList()));\n        case \"hilbert\":\n          return new Hilbert(\n              Stream.of(transform.references())\n                  .map(ref -> DOT.join(ref.fieldNames()))\n                  .map(org.apache.iceberg.expressions.Expressions::ref)\n                  .collect(Collectors.toList()));\n        default:\n          throw new UnsupportedOperationException(\"Transform is not supported: \" + transform);\n      }\n\n    } else if (expr instanceof NamedReference) {\n      NamedReference ref = (NamedReference) expr;\n      return org.apache.iceberg.expressions.Expressions.ref(DOT.join(ref.fieldNames()));\n\n    } else {\n      throw new UnsupportedOperationException(\"Cannot convert unknown expression: \" + expr);\n    }\n  }\n\n  /**\n   * Converts Spark transforms into a {@link PartitionSpec}.\n   *\n   * @param schema the table schema\n   * @param partitioning Spark Transforms\n   * @return a PartitionSpec\n   */","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java#L395-L431","documentation":"Spark3Util.toIcebergTerm converts Spark sort/cluster expression transforms into Iceberg expressions. The default case of the transform switch throws UnsupportedOperationException when the Spark transform (e.g. an unsupported bucket/year variant or other function transform) has no Iceberg equivalent.","triggerScenarios":"Cluster/sort DDL using a Spark transform that the switch does not cover (unsupported named transform such as certain time units or functions) passed to toIcebergTerm.","commonSituations":"Using Spark SQL transform functions in CLUSTER BY / SORTED BY that Iceberg partitioning/sorting does not define; version drift between Spark transforms and Iceberg support matrix.","solutions":["Restrict to supported transforms: identity, bucket, truncate, year/month/day/hour (and supported sort orders)","Rewrite the query to use an Iceberg-supported transform expression","Check the Iceberg version's supported transform list before using a transform in DDL"],"exampleFix":"// before\nCLUSTER BY (sha2(col, 32));\n// after\nCLUSTER BY (bucket(16, col));","handlingStrategy":"validation","validationCode":"java.util.Set<String> supported = java.util.Set.of(\n    \"identity\",\"bucket\",\"truncate\",\"years\",\"months\",\"days\",\"hours\");\nfor (Transform<?, ?> t : transforms) {\n  if (!supported.contains(t.name())) throw new IllegalArgumentException(\"Unsupported transform: \" + t.name());\n}","typeGuard":null,"tryCatchPattern":"try {\n  Spark3Util.toIcebergTerm(expr);\n} catch (UnsupportedOperationException e) {\n  // rewrite the transform to a supported one and retry\n}","preventionTips":["Restrict CLUSTER/SORT DDL to Iceberg-supported transforms","Consult the Iceberg transforms doc before allowing arbitrary Spark expressions","Validate transforms at DDL-parse time, not at apply time"],"tags":["spark","transform","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}