Skip to content

[Bug] AuditLogTable constructor directly modifies shared FileStoreTable.options, causing column misalignment or ClassCastException when querying base table after $audit_log #8803

Description

@L-Gryps

Search before asking

  • I searched in the issues and found nothing similar.

Paimon version

1.4.2

Compute Engine

Flink

Minimal reproduce step

Reproduction SQL verified with sql-client:

  1. Create table with option 'table-read.sequence-number.enabled' = 'true'
    CREATE TABLE user_role (
    id INT,
    user_id INT,
    role_id INT
    ) WITH (
    'table-read.sequence-number.enabled' = 'true'
    );

  2. Insert test data
    INSERT INTO user_role VALUES (1,1,2),(3,3,5),(5,2,4);

  3. Query audit log system table
    SELECT * FROM user_role$audit_log;
    +---------+------------------+----+---------+---------+
    | rowkind | _SEQUENCE_NUMBER | id | user_id | role_id |
    +---------+------------------+----+---------+---------+
    | +I | 8 | 1 | 1 | 2 |
    | +I | 10 | 3 | 3 | 5 |
    | +I | 7 | 5 | 2 | 4 |
    +---------+------------------+----+---------+---------+

  4. Query base table again
    SELECT * FROM user_role;
    +----+---------+---------+
    | id | user_id | role_id |
    +----+---------+---------+
    | 8 | 1 | 1 |
    | 10 | 3 | 3 |
    | 7 | 5 | 2 |
    +----+---------+---------+

You can also create a table with STRING column to trigger ClassCastException.

What doesn't meet your expectations?

Observed Behavior

  1. Numeric column table: base table query columns are misaligned. The value of _SEQUENCE_NUMBER leaks into the first column, all data columns shift right.
  2. Table contains STRING column: Throw ClassCastException
    HeapLongVector cannot be cast to BytesColumnVector

Expected Behavior

After querying $audit_log, querying the base table should return normal data without extra _SEQUENCE_NUMBER column, column order consistent with table schema.

Root Cause

AuditLogTable constructor directly mutates wrapped FileStoreTable's shared options map in-place:

this.wrapped.options().put(KEY_VALUE_SEQUENCE_NUMBER_ENABLED.key(), "true");

### Anything else?

_No response_

### Are you willing to submit a PR?

- [x] I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions