Skip to content

fix(partitions): align paths with compacted partition fields#1332

Open
fallintoplace wants to merge 2 commits into
apache:mainfrom
fallintoplace:fix/partition-to-path-compacted-fields
Open

fix(partitions): align paths with compacted partition fields#1332
fallintoplace wants to merge 2 commits into
apache:mainfrom
fallintoplace:fix/partition-to-path-compacted-fields

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

Summary

make PartitionToPath walk the same active compacted partition-field sequence as PartitionType
reuse that active-field computation in both code paths to keep them aligned
add a regression test for a spec whose leading partition source column has been dropped from the current schema

Why

PartitionSpec.PartitionType explicitly compacts away partition fields whose source columns are no longer present in the current schema. But PartitionSpec.PartitionToPath still indexed into ps.fields positionally while reading values from that compacted partition record.

When an earlier partition source column had been dropped, the compacted record shifted left while PartitionToPath kept using names and transforms from the full spec. That could label values under the wrong partition field names or apply the wrong transform when generating partition paths.

Testing

go test . -run 'Test(PartitionType|PartitionSpecToPath|PartitionSpecToPathWithDroppedLeadingSourceColumn)$' -count=1
go test . -count=1
go test ./table -count=1
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.4 run --timeout=10m . ./table/...
git diff --check

@fallintoplace fallintoplace requested a review from zeroshade as a code owner June 27, 2026 14:52

@tanmayrauth tanmayrauth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, well-scoped fix, traced it through the snapshot-summary caller and the compacted record lines up with the new active-field indexing. LGTM. One out-of-scope question and a naming nit inline.

getRecordPartitions in table/partitioned_fanout_writer.go has the same shape this PR is fixing, it sizes its loop by spec.PartitionType(schema).FieldList (compacted) but indexes spec.Field(i) (full spec). It shouldn't trigger today since the active write spec shouldn't have a dropped source column, but is that guaranteed? Might be worth aligning it on activePartitionFields too (or dropping a comment) so the two paths don't drift. Happy to leave it for a follow-up since it's outside this PR's scope.

Comment thread partitions.go Outdated
return id
}

type partitionFieldType struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is really a (field, resolvedType) pair rather than a "type" — activePartitionField might read a touch clearer.

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.

2 participants