apache/seatunnel · warning · UnsupportedOperationException

%s does not support replacing comments

Error message

%s does not support replacing comments

What it means

Column.copyWithComment is an optional capability: the base Column implementation throws UnsupportedOperationException, and subclasses that do not support comment mutation rely on this default. Callers must only invoke it on column types that override it (e.g. PhysicalColumn).

Source

Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/Column.java:239

    /** Returns a copy of the column with a replaced {@link SeaTunnelDataType}. */
    public abstract Column copy(SeaTunnelDataType<?> newType);

    /** Returns a copy of the column. */
    public abstract Column copy();

    /** Returns a copy of the column with a replaced name. */
    public abstract Column rename(String newColumnName);

    /** Returns a copy of the column with a replaced sourceType. */
    public abstract Column reSourceType(String sourceType);

    /**
     * Returns a copy of the column with a replaced comment.
     *
     * <p>Subclasses should override this method when they support comment mutation.
     */
    public Column copyWithComment(String comment) {
        throw new UnsupportedOperationException(
                String.format("%s does not support replacing comments", getClass().getName()));
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Only call copyWithComment after checking the column type supports it, or reconstruct the column manually
  2. Override copyWithComment in the custom Column subclass
  3. Use the column's specific builder/of(...) to produce a new instance with the new comment

Example fix

// before
Column c2 = column.copyWithComment("new comment"); // throws for MetadataColumn
// after
if (column instanceof PhysicalColumn) {
    Column c2 = column.copyWithComment("new comment");
} else {
    Column c2 = MetadataColumn.of(column.getName(), column.getDataType(), ..., "new comment");
}
Defensive patterns

Strategy: type-guard

Type guard

boolean supportsComment = column instanceof PhysicalColumn;

Try / catch

try { c2 = column.copyWithComment(c); } catch (UnsupportedOperationException e) { /* rebuild column manually */ }

Prevention

When it happens

Trigger: Calling copyWithComment on a Column subclass that does not override it (e.g. MetadataColumn or other non-mutating column types), typically during schema evolution/table sync that rewrites comments.

Common situations: Schema-sync or catalog-sync tools propagating comment changes to all column types; custom Column implementations that never overrode copyWithComment.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/e67c5c8a649ae824. Report an issue: GitHub.