Skip to content

fix: ignore_column_order also sorts the fields of nested structs - #200

Merged
SemyonSinchenko merged 1 commit into
MrPowers:mainfrom
nanjeshramesh:fix-146-nested-ignore-column-order
Oct 19, 2026
Merged

SemyonSinchenko merged 1 commit into
MrPowers:mainfrom
nanjeshramesh:fix-146-nested-ignore-column-order

Conversation

@nanjeshramesh

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Fixes #146.

ignore_column_order=True only sorted the top level columns. Two DataFrames whose struct columns listed their fields in a different order, for example array<struct<updated_at, id>> against array<struct<id, updated_at>>, still raised a SchemasNotEqualError.

This sorts the fields of every struct in the schema before comparing, including structs inside arrays and maps (map keys and values). It applies to assert_df_equality and assert_approx_df_equality. Null structs stay null, and columns without structs are left as they are. The default (ignore_column_order=False) is unchanged, and the README notes the behavior.

Tests cover nested structs, structs in arrays, map values and map keys, null structs, columns with no structs, the approx variant, that different values still fail, and that the default still fails on a different field order.

ignore_column_order only sorted the top level columns, so two DataFrames whose
struct columns listed their fields in a different order still raised a
SchemasNotEqualError. Sort the fields of every struct in the schema,
including structs inside arrays and maps, before comparing.

@SemyonSinchenko SemyonSinchenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

~LGTM

@SemyonSinchenko
SemyonSinchenko merged commit 0b2d3a7 into MrPowers:main Oct 19, 2026
12 checks passed
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.

Add option to ingore order of array items (but check schema of array items)

2 participants