{"record":{"id":"7b15aad106390330","repo":"apache/iceberg","slug":"apply-value-is-deprecated-use-bind-type-apply-v","errorCode":null,"errorMessage":"apply(value) is deprecated, use bind(Type).apply(value)","messagePattern":"apply\\(value\\) is deprecated, use bind\\(Type\\)\\.apply\\(value\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/transforms/Transform.java","lineNumber":49,"sourceCode":" * A transform function used for partitioning.\n *\n * <p>Implementations of this interface can be used to transform values, check or types, and project\n * {@link BoundPredicate predicates} to predicates on partition values.\n *\n * @param <S> Java class of source values\n * @param <T> Java class of transformed values\n */\npublic interface Transform<S, T> extends Serializable {\n  /**\n   * Transforms a value to its corresponding partition value.\n   *\n   * @param value a source value\n   * @return a transformed partition value\n   * @deprecated use {@link #bind(Type)} instead; will be removed in 2.0.0\n   */\n  @Deprecated\n  default T apply(S value) {\n    throw new UnsupportedOperationException(\n        \"apply(value) is deprecated, use bind(Type).apply(value)\");\n  }\n\n  /**\n   * Returns a function that applies this transform to values of the given {@link Type type}.\n   *\n   * @param type an Iceberg {@link Type}\n   * @return a {@link Function} that applies this transform to values of the given type.\n   */\n  default SerializableFunction<S, T> bind(Type type) {\n    throw new UnsupportedOperationException(\"bind is not implemented\");\n  }\n\n  /**\n   * Checks whether this function can be applied to the given {@link Type}.\n   *\n   * @param type a type\n   * @return true if this transform can be applied to the type, false otherwise","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/transforms/Transform.java#L31-L67","documentation":"Transform.apply(value) is a deprecated default method that always throws UnsupportedOperationException to force migration to the bound API. Iceberg transforms must be bound to a source Type (via bind(Type)) before use, because the actual transform function depends on the column's type. Calling the unbound apply() directly is no longer supported and will be removed in 2.0.0.","triggerScenarios":"Directly calling transform.apply(value) on any Transform (e.g. Transforms.bucket(...).apply(v)) instead of first calling bind(type) and invoking apply on the returned SerializableFunction.","commonSituations":"Older code written against pre-binding Iceberg APIs that was upgraded to a newer Iceberg version; copy-pasted examples from outdated documentation.","solutions":["Call bind(type) first and use the returned function: transform.bind(sourceType).apply(value)","Replace deprecated apply(value) call sites with the bound pattern","Catch UnsupportedOperationException during migration to find remaining unbound call sites"],"exampleFix":"// before\nObject part = Transforms.bucket(16).apply(value);\n// after\nObject part = Transforms.bucket(16).bind(sourceType).apply(value);","handlingStrategy":"type-guard","validationCode":"if (transform instanceof BoundTransform || function != null) { /* safe to apply */ }","typeGuard":"static <S, T> SerializableFunction<S, T> bound(Transform<S, T> t, Type type) {\n  return t.bind(type);\n}","tryCatchPattern":"try { return transform.bind(type).apply(value); } catch (UnsupportedOperationException e) { throw new IllegalStateException(\"Transform not bound; call bind(type) first\", e); }","preventionTips":["Never call Transform.apply(value) directly — always bind first","Grep the codebase for \".apply(\" on Transform instances and migrate to bind(type).apply(...)","Note that apply(value) is removed in Iceberg 2.0.0 — migrate proactively"],"tags":["java","iceberg","transform","deprecated","unbound-transform"],"backgroundTag":"deprecated-api-usage","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"}