{"record":{"id":"fa40f37ba2e57cd8","repo":"apache/iceberg","slug":"this-getclass-getname-doesn-t-implement-ad","errorCode":null,"errorMessage":"this.getClass().getName() + \" doesn't implement addNonDefaultSpec()\"","messagePattern":"this\\.getClass\\(\\)\\.getName\\(\\) \\+ \" doesn't implement addNonDefaultSpec\\(\\)\"","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/UpdatePartitionSpec.java","lineNumber":133,"sourceCode":"  /**\n   * Rename a field in the partition spec.\n   *\n   * @param name name of the partition field to rename\n   * @param newName replacement name for the partition field\n   * @return this for method chaining\n   * @throws IllegalArgumentException If name doesn't identify a column in the schema or if this\n   *     change conflicts with other additions, removals, or renames.\n   */\n  UpdatePartitionSpec renameField(String name, String newName);\n\n  /**\n   * Sets that the new partition spec will be NOT set as the default partition spec for the table,\n   * the default behavior is to do so.\n   *\n   * @return this for method chaining\n   */\n  default UpdatePartitionSpec addNonDefaultSpec() {\n    throw new UnsupportedOperationException(\n        this.getClass().getName() + \" doesn't implement addNonDefaultSpec()\");\n  }\n}\n","sourceCodeStart":115,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/UpdatePartitionSpec.java#L115-L137","documentation":"UpdatePartitionSpec.addNonDefaultSpec() is a default method that throws UnsupportedOperationException when the concrete implementation does not support adding a partition spec that is not set as the table's default spec. Like other optional API methods, only implementations that support this behavior override it.","triggerScenarios":"Calling updatePartitionSpec(...).addNonDefaultSpec() on an implementation that has not overridden the default, e.g. certain catalog- or transaction-backed UpdatePartitionSpec instances.","commonSituations":"Trying to evolve a table with a non-default (legacy) partition spec via an update object obtained from a context that only supports default-spec updates; writing generic table-evolution code that assumes all implementations support the method.","solutions":["Use the default-spec update path (apply the new spec as the table's default) instead of addNonDefaultSpec().","Check the implementation class (named in the message) for supported operations before calling optional methods.","Implement addNonDefaultSpec() if you own the UpdatePartitionSpec implementation.","Upgrade Iceberg if support was added in a later version."],"exampleFix":"// before\ntransaction.updatePartitionSpec().addNonDefaultSpec().addField(\"day\");\n\n// after\ntransaction.updatePartitionSpec().addField(\"day\"); // default spec update","handlingStrategy":"try-catch","validationCode":"// no pre-call check is exposed; consult the implementation's supported operations","typeGuard":"boolean supportsNonDefaultSpec = update instanceof BaseUpdatePartitionSpec; // implementer-specific check","tryCatchPattern":"try {\n  update.addNonDefaultSpec().addField(\"day\");\n} catch (UnsupportedOperationException e) {\n  // fall back to default-spec update\n  update.addField(\"day\");\n}","preventionTips":["Only call addNonDefaultSpec() on implementations documented to support it.","Prefer default-spec evolution unless you specifically need a non-default spec.","Read the class name in the error to identify the lacking implementation."],"tags":["unsupported-operation","partition-spec","api"],"backgroundTag":"unsupported-operation","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"}