{"record":{"id":"522c71166574b252","repo":"apache/beam","slug":"could-not-find-a-partition-transform-for","errorCode":null,"errorMessage":"Could not find a partition transform for '{}'.","messagePattern":"Could not find a partition transform for '(.+?)'\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/PartitionUtils.java","lineNumber":107,"sourceCode":"  static PartitionSpec toPartitionSpec(@Nullable List<String> fields, Schema schema) {\n    if (fields == null) {\n      return PartitionSpec.unpartitioned();\n    }\n    PartitionSpec.Builder builder = PartitionSpec.builderFor(schema);\n\n    for (String field : fields) {\n      boolean matched = false;\n      for (Map.Entry<Pattern, BiFunction<PartitionSpec.Builder, Matcher, PartitionSpec.Builder>>\n          entry : TRANSFORMATIONS.entrySet()) {\n        Matcher matcher = entry.getKey().matcher(field);\n        if (matcher.find()) {\n          builder = entry.getValue().apply(builder, matcher);\n          matched = true;\n          break;\n        }\n      }\n      if (!matched) {\n        throw new IllegalArgumentException(\n            \"Could not find a partition transform for '\" + field + \"'.\");\n      }\n    }\n\n    return builder.build();\n  }\n\n  private static final Map<Pattern, Function<Matcher, Term>> TERMS =\n      ImmutableMap.of(\n          HOUR,\n          matcher -> Expressions.hour(checkStateNotNull(matcher.group(1))),\n          DAY,\n          matcher -> Expressions.day(checkStateNotNull(matcher.group(1))),\n          MONTH,\n          matcher -> Expressions.month(checkStateNotNull(matcher.group(1))),\n          YEAR,\n          matcher -> Expressions.year(checkStateNotNull(matcher.group(1))),\n          TRUNCATE,","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/PartitionUtils.java#L89-L125","documentation":"PartitionUtils.toPartitionSpec translates Beam's partitioning DSL strings (e.g. year(ts), bucket[16](id), truncate[10](name)) into an Iceberg PartitionSpec. Each field string must match one of the registered transform regexes; if no regex matches, IllegalArgumentException is thrown because the transform cannot be represented.","triggerScenarios":"Calling Read.from(table).withPartitioning/toPartitionSpec with a partition field string not matching supported patterns — misspelled transform (years vs year), wrong bracket syntax (bucket(16) instead of bucket[16]), unsupported transform (identity on a type without support), or a transform name entirely absent from the matcher list.","commonSituations":"Copy-pasting Iceberg DDL transform syntax (e.g. 'month(ts)') that uses a different bracket convention than Beam's matcher expects; using transforms like 'void' or bucket sizes not covered; typos in column names inside the transform string.","solutions":["Check Beam PartitionUtils source for the exact accepted regex patterns and match your strings, e.g. 'year(col)', 'month(col)', 'day(col)', 'hour(col)', 'bucket[N](col)', 'truncate[L](col)'","Use identity by passing the bare column name if you just want untransformed partitioning","Fix bracket syntax: use square brackets for parameters, e.g. bucket[8](user_id) not bucket(8)(user_id)","Only use transforms that exist in the table's actual PartitionSpec; inspect table.spec() to copy field names"],"exampleFix":"// before\n\"bucket(16)(user_id)\"\n// after\n\"bucket[16](user_id)\"","handlingStrategy":"validation","validationCode":"java.util.regex.Pattern p = java.util.regex.Pattern.compile(\"(year|month|day|hour)\\\\((\\\\w+)\\\\)|(bucket)\\\\[(\\\\d+)\\\\]\\\\((\\\\w+)\\\\)|(truncate)\\\\[(\\\\d+)\\\\]\\\\((\\\\w+)\\\\)|^(\\\\w+)$\");\nif (!p.matcher(partitionField).matches()) throw new IllegalArgumentException(\"Invalid partition transform: \" + partitionField);","typeGuard":"null","tryCatchPattern":"try {\n  PartitionSpec spec = PartitionUtils.toPartitionSpec(schema, partitionFields);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Partition transform syntax rejected: {}\", e.getMessage());\n  // fix string and retry, or fall back to identity partitioning\n}","preventionTips":["Use exactly the documented syntax: day(col), bucket[8](col), truncate[10](col)","Copy transform names from table.spec() rather than hand-writing","Add a startup validation that parses all partition strings before launching the pipeline"],"tags":["java","iceberg","beam","partitioning","configuration"],"backgroundTag":"invalid-argument-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}