Skip to content

[core] Rebuild the default value row when the write type changes - #10208

Open
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-014-default-value-row
Open

LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-014-default-value-row

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Purpose

TableWriteImpl builds its DefaultValueRow once in the constructor, sized to the constructor row type. withWriteType refreshed the write type and the not-null indexes but left the DefaultValueRow untouched, so once the write type changed the stale default value row no longer matched the rows it wraps. The Spark copy-on-write rewrite writes with the row-tracking-extended type, and a partial write uses a narrowed projection, both of which shift arity and positions. Reading an appended position that is null, such as the null sequence number the rewrite carries, fell through to the default row's underlying array of the old length and crashed the write with an ArrayIndexOutOfBoundsException. This rebuilds the default value row from the new write type so its arity and positions follow the type.

Tests

Added testWithWriteTypeRebuildsDefaultValueRow: after switching to the row-tracking-extended write type with a null sequence number, an explicit value on the defaulted column survives the type change.

Added testWithWriteTypeSubstitutesDefaultValue: same shape but the defaulted column is left null, so the rebuilt default value row fills the column default at its new position.

API and Format

No.

Documentation

No.

TableWriteImpl sized its DefaultValueRow once, from the row type of the
constructor. withWriteType only refreshed the write type and the
not-null indexes, so after switching to a different type — the Spark
copy-on-write rewrite writes with the row-tracking-extended type, a
partial write with a narrower projection — the stale default value row
no longer matched the rows it wraps: reading one of the appended
positions that is null (rewritten rows carry null sequence numbers)
fell through to the default row's underlying array of the old length
and crashed the write with an ArrayIndexOutOfBoundsException.

Rebuild the default value row from the new write type, whose fields
carry the same column defaults at the new positions.

Assisted-by: GLM-5.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant