Skip to content

Refactor findSchemaElement to use named struct and add column_index#35

Merged
unexge merged 1 commit intomainfrom
push-npomsloqrrll
Feb 1, 2026
Merged

Refactor findSchemaElement to use named struct and add column_index#35
unexge merged 1 commit intomainfrom
push-npomsloqrrll

Conversation

@unexge
Copy link
Copy Markdown
Owner

@unexge unexge commented Feb 1, 2026

Summary

Problem: The findSchemaElement method returned a schema index that required users to subtract 1 to get the column index (as seen in the NYC taxi example: file.findSchemaElement(&.{name}).?.index - 1).

Solution:

  • Define a named struct SchemaInfo instead of anonymous struct with fields:

    • column_index - index into the row group's columns array (leaf elements only)
    • max_definition_level - for handling nullability
    • max_repetition_level - for handling repeated elements
    • elem - the schema element itself
  • Update findSchemaElement to track the column index by counting only leaf elements (elements without children) as it traverses the schema tree.

  • Update the NYC taxi example and README to use column_index directly instead of index - 1.

  • Add tests for:

    • Flat schema: verifies column indices 0, 1, 2 for columns foo, bar, ham
    • Non-existent paths: verifies null is returned
    • Optional columns: verifies correct definition/repetition levels
    • Nested schema: verifies correct column indices for nested struct fields (e.g., roll_num.min → 0, roll_num.variance → 5, PC_CUR.min → 6)

- Define SchemaInfo struct instead of anonymous struct
- Add column_index field that corresponds to the index in row group columns array
- Track column_index by counting only leaf elements (elements without children)
- Update NYC taxi example to use column_index directly instead of index - 1
- Update README example to use column_index
- Add tests for findSchemaElement covering flat and nested schemas
@unexge unexge merged commit b7ef1d0 into main Feb 1, 2026
1 check passed
@unexge unexge deleted the push-npomsloqrrll branch February 1, 2026 13:47
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