fix: identity equality for expression nodes; eager equijoin collision check - #3
Merged
Merged
Conversation
… check A1: The node dataclasses used the default eq=True, generating a structural __eq__ that reaches Attr.__eq__ (which returns a Predicate whose __bool__ raises) — so node1 == node2, "node in [...]", and set(nodes) raised PredicateError, and the derived __hash__ raised TypeError on the dict fields of Grouping/Rename. Expression-tree equivalence is identity, not structure, so all 12 node dataclasses now use eq=False (object identity for __eq__ and __hash__). A2: Equijoin validated only join-attribute existence at construction and deferred its ambiguous-output-name check to _schema(), unlike every other node. Move the collision check into __post_init__ (eager-validation invariant); _schema() now only shapes the result. Adds TestNodeIdentity and TestEquijoinEagerValidation. Closes A1, A2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P2 API/semantics fixes (closes A1, A2)
A1 — expression nodes had value-equality enabled, and it raised
The node dataclasses used the default
eq=True. The generated structural__eq__compares fields, reachingAttr.__eq__, which returns aPredicatewhose
__bool__raisesPredicateError. So any of these blew up:eq=True+frozen=Truealso synthesized a__hash__over the fields,making
GroupingandRename(dict-valued fields) unhashable —hash(node)raisedTypeError.Expression-tree equivalence is identity, not structure (the engine check
uses
is;Attr.__hash__already chose identity). Fix:eq=Falseon all12 node dataclasses, so
__eq__/__hash__fall back to object identity.A2 — Equijoin deferred its collision check past construction
Equijoin.__post_init__validated only that the join attributes exist; theambiguous-output-name
SchemaErrorlived in_schema()and surfaced only ona later
.schema()call — unlike every other node, which validates eagerly.Fix: move the collision check into
__post_init__(byte-identical logic),leaving
_schema()to only shape the result schema.Tests
TestNodeIdentity(7):==is identity (self True, distinct False, noraise) even with predicate-bearing children; membership checks don't raise;
Grouping/Renameare hashable and identity-keyed; a guard asserts everyone of the 12 node classes inherits
object.__eq__/object.__hash__.TestEquijoinEagerValidation(2): colliding non-join column raisesSchemaErrorat construction; the dropped right join column is not afalse collision.
Local gate green:
ruff,mypy,pytest(106 passed, 15 skipped).