Repository navigation
Conversation
| raise ValueError( | ||
| f"Option '{sequence_field_key}' must not be empty. " | ||
| "Omit or remove it to use the default record ordering." | ||
| ) |
There was a problem hiding this comment.
In CoreOptions.sequence_field() (pypaimon/common/options/core_options.py:1645-1647), trailing empty segments are stripped via:
segments = raw.split(",")
while segments and segments[-1] == "":
segments.pop()
return [name.strip() for name in segments]Because of that loop, a comma-only value like "," (or ",,,") also evaluates core_options.sequence_field() to [], reproducing the exact same issue as "" (accepted on CREATE / ALTER SET, treated as omitted by pure Python reads, and rejected by DataFusion with Sequence field '' not found in table schema). Similarly, whitespace-only values like " " pass == "" at schema commit time and only fail later on read.
Since core_options = CoreOptions(Options(options)) is already constructed right below on line 811, consider checking not str(options.get(sequence_field_key)).strip() or not core_options.sequence_field() when sequence_field_key in options:
core_options = CoreOptions(Options(options))
sequence_field_key = CoreOptions.SEQUENCE_FIELD.key()
if sequence_field_key in options and (
not str(options[sequence_field_key]).strip()
or not core_options.sequence_field()
):
raise ValueError(
f"Option '{sequence_field_key}' must not be empty. "
"Omit or remove it to use the default record ordering."
)There was a problem hiding this comment.
Thanks for pointing out these cases. I checked both CREATE and ALTER SET on a primary-key table (id INT, ts INT) with bucket=1 and merge-engine=partial-update. For ALTER SET, the table started with sequence.field='ts'. Each result below applies to both operations.
| sequence.field | Java FileSystemCatalog | PyPaimon before this PR | PyPaimon with this PR | DataFusion (pypaimon-rust 0.5.0) |
|---|---|---|---|---|
| '' | Rejects | Accepts | Rejects | Rejects |
| ',' | Accepts | Accepts | Accepts | Rejects |
| ' ' | Rejects | Accepts | Accepts | Rejects |
For example, after writing (1, 10) and then (1, 9) in separate commits, the table ordered by ts returns 10. Before this PR, setting sequence.field='' makes PyPaimon return 9 without any new writes. With this PR, the ALTER is rejected and the next read still returns 10. That is the behavior #11639 addresses.
Rejecting ',' in PyPaimon would introduce a difference from Java. Whitespace-only values are a good follow-up. I also checked the proposed guard against an existing table with ' ' and found that it blocks an ALTER that only changes the table comment.
So I’d keep this PR and its regression tests focused on the literal empty string.
Purpose
Fixes #11639
PyPaimon accepts and saves an empty
sequence.fieldon CREATE and ALTER SET. On a table ordered byts, setting the option to an empty string can change which row is returned without writing any new data because pure Python reads fall back to the default record ordering.Reject the explicit empty string before publishing the schema. A rejected ALTER preserves the previous schema and ordering. Users can omit or remove the option to use the default record ordering.
Tests