Skip to content

Feat: support semantic_equality for datatypes - #10902

Closed
Rich-T-kid wants to merge 7 commits into
apache:mainfrom
Rich-T-kid:rich-T-kid/semantic-datatype-equality
Closed

Rich-T-kid wants to merge 7 commits into
apache:mainfrom
Rich-T-kid:rich-T-kid/semantic-datatype-equality

Conversation

@Rich-T-kid

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Arrow's derived PartialEq on DataType/Field requires exact equality (name, nullability, metadata), so logically-equivalent types like List<item: Int32> and List<element: Int32> compare unequal.

What changes are included in this PR?

Add EquivlenceGauge and DataType::semantic_equality/equal_datatypes to compare nested types (List, FixedSizeList, Struct, Union, Map, Dictionary, RunEndEncoded) while optionally ignoring field name, nullability, and/or metadata.

Are these changes tested?

Yes, unit tests in datatype.rs.

Are there any user-facing changes?

Yes, new public API: EquivlenceGauge, DataType::semantic_equality, equal_datatypes.

Comment thread arrow-schema/src/lib.rs Resolved
Comment thread arrow-schema/src/lib.rs Outdated
/// field, including its name, nullability, and metadata. `EquivalenceGauge` lets
/// callers relax those checks, e.g. to treat `List<item: Int32>` and
/// `List<element: Int32>` as equivalent by setting `check_field_name` to `false`.
#[derive(Clone, Debug)]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

may be worth adding a couple constructor methods like

  • Default (all true)
  • new_true (all true)
  • new_false (all false)

but it may also be useful for callers to be explicit each time they call equal_datatypes or semantic_equality 🤔

@Rich-T-kid Rich-T-kid Aug 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thinking about this a bit more, a default constructor (all false) should be enough.

The point of the SemanticEqualityOptions is to relax the strictness of comparison between datatypes, if users want a more strict comparison they should manually opt in.

Comment thread arrow-schema/src/lib.rs Resolved
Comment thread arrow-schema/src/datatype.rs Resolved
Comment thread arrow-schema/src/datatype.rs Resolved

@AndreaBozzo AndreaBozzo 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.

nothing else to flag from my side, lgtm

@Rich-T-kid Rich-T-kid changed the title minor: support semantic_equality for datatypes Feat: support semantic_equality for datatypes Sep 13, 2026
@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

cc @alamb since you created the issue

@Rich-T-kid Rich-T-kid closed this Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a way to compare datatype for "semantic compatibility / equality"

3 participants