Skip to content

fix: write partitioned tables that have a _partition column - #139

Draft
xanderbailey wants to merge 1 commit into
apache:mainfrom
xanderbailey:xb/partition-column-name-clash
Draft

xanderbailey wants to merge 1 commit into
apache:mainfrom
xanderbailey:xb/partition-column-name-clash

Conversation

@xanderbailey

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

None filed.

Rationale for this change

Inserting into a partitioned table that has its own _partition column fails with Partition column is not a StructArray. repartition, sort_by_partition and the partition splitter all find the projected partition values by name, and the table's column comes first.

What changes are included in this PR?

  • Look up the projected column as the last field named _partition, since project_with_partition always appends it after the table columns.
  • TaskWriter moves that column to the front before splitting (the splitter takes the first match), then drops it from the batches it writes.

Longer term the splitter in iceberg-rust could take a column index instead.

Are these changes tested?

Yes: an insert_into test, plus unit tests for TaskWriter (fanout and clustered), repartition and sort_by_partition. The insert_into test reads the data files directly, because scanning _partition currently returns the metadata column (apache/iceberg-rust#3362).

repartition, sort_by_partition and the partition splitter found the
projected partition values by name, so a table column named
`_partition` was read in their place and the INSERT failed.

Look up the projected column as the last field with that name, and move
it to the front before splitting since the splitter takes the first
match.
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