Skip to content

Adopt type aliases for all IDs (schemas, views, fields, etc.) #3524

Open

Description

@dannycjones

I'm proposing to adopt Rust type aliases for schema IDs, field IDs, etc..

Bits of this already exist for schema IDs. I propose completing that, and adopting this across other ID types.

Firstly, this improves readability as things like hash maps will immediately convey what it is mapping. For example: HashMap<SchemaId, Schema>, HashMap<FieldId, ArrowFieldIdx>.

Secondly, should we wish to migrate to Rust's newtype idiom then this is already covering half the battle. We'd only need to update construction and unwrapping points.

I'll start with Schema ID and slowly migrate bits across. Please share if you have any concerns here. Note, I am not recommending migrating to newtypes at this time, that is a separate discussion which requires much more nuance.

Activity

  1. dannycjones commented on Oct 24, 2026

    @dannycjones
    ContributorAuthor

    Rough plan. I'm particularly interested in FieldId and the Arrow and Parquet indices. I'm expecting to need to rework some of the Arrow modules that have field IDs and Arrow columns indices all over, and it would be nice to have them labelled up by the time I'm working on those changes.

    First phase:

    1. SchemaId: use the existing alias wherever a schema ID is a bare i32. (refactor(spec): adopt SchemaId type alias everywhere #3525)
    2. ViewVersionId: use the existing alias for view version IDs, and fix a builder field mistakenly typed as SchemaId. (refactor(spec): adopt ViewVersionId type alias everywhere #3526)
    3. PartitionFieldId: add an i32 alias for partition field IDs, a separate ID space from schema field IDs.
    4. FieldId (spec): add an i32 alias for schema field IDs and adopt it in the spec module.
    5. FieldId (everywhere else): adopt FieldId across the rest of the crate and the Python bindings. Separated because this one is likely to be pretty big, and disruptive to open PRs.
    6. ArrowFieldIndex: add usize alias so its clearer when we're working with Arrow field indices.
    7. ParquetColumnIndex: add usize alias so its clearer when we're working with Parquet column indices.

    Second phase (longer tail, I'm less interested but worth doing):

    1. SnapshotId: add an i64 alias for snapshot IDs.
    2. PartitionSpecId: add an i32 alias for partition spec IDs.
    3. SortOrderId (breaking): add the alias and change sort order IDs from i64 to i32, matching the spec's int.
    4. RowId (breaking): add an i64 alias for row IDs, changing the ones typed u64 to i64, matching the spec's long.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions