Repository navigation
fix(logical_types)!: a stored set of user-class values has a canonical order (ITL-922) #639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
eywalker
wants to merge
24
commits into
main
from
eywalker/itl-922-a-set-of-a-user-registered-logical-type
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ab21bea
fix(logical_types): order a set of a scalar-stored logical type canon…
eywalker 7328143
Merge remote-tracking branch 'origin/main' into eywalker/itl-922-a-se…
eywalker faa29d9
fix(logical_types)!: canonically order stored sets of user-class valu…
eywalker 4b5f375
fix(logical_types): order logical sets after Arrow coercion
eywalker 216aeea
fix(logical_types): canonicalize nested stored sets and batch column …
eywalker 8eee15e
perf(logical_types): batch stored set sorting and rank list keys nati…
eywalker c9daaa5
perf(logical_types): batch canonical ordering for struct sets
eywalker e91dedb
perf(logical_types): isolate and batch struct-set storage
eywalker a44f381
fix(logical_types): restore direct set decoding and speed small writes
eywalker b522c55
fix(logical_types): restore schema overrides and wrapped set iteration
eywalker 3c67c76
fix(logical_types): honor explicit Arrow set schemas
eywalker 32a7c0a
test(logical_types): reuse default Arrow extensions in native writes
eywalker c9236ff
perf(logical_types): resolve explicit writer dispatch by type
eywalker a422250
chore: merge origin/main into ITL-922
eywalker 98d89f5
test(logical_types): use a concrete schema for registration
eywalker ef72f45
fix(logical_types): skip projected-away set columns
eywalker c27a08b
fix(logical-types): honor empty projections and retain batch ordering
eywalker 8956cff
chore: merge origin/main into ITL-922
eywalker 11c5afc
chore: merge origin/main into ITL-922
eywalker 14434e0
fix(logical-types): preserve set validation across conversion paths
eywalker c59f893
fix(logical-types): preserve values in set projections
eywalker 6ab9b67
fix(logical-types): restore reviewed set conversion behavior
eywalker 4a0bd48
chore: merge origin/main into ITL-922
eywalker 39faca3
fix(typing): record Arrow date scalar stub omission
eywalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ### Breaking changes and migration | ||
|
|
||
| - Rebuilding rows with a `set[T]` of user-class values can change their hashes | ||
| (ITL-922). The elements now sort by their stored fields in declared order. | ||
| For example, a numeric field with `2` sorts before `10`. Orcapod recomputes | ||
| cached results whose input hashes change when the data is rebuilt. | ||
|
|
||
| ### Fixed | ||
|
|
||
| - Sets of struct-stored logical types are ordered after Arrow coerces each element | ||
| to the declared storage type (ITL-922). The sort descends into nested structs | ||
| and lists, with `None` first. Nested dict keys and set items are ordered after | ||
| coercion too. A NaN at any depth, incomparable values, or two keys or elements | ||
| with equal storage raise `CanonicalOrderError` naming the column. | ||
| - Sets of user-defined scalar-stored types keep their native sort and reject | ||
| NaNs or duplicate storage values after Arrow coercion. | ||
| - Table conversion batches struct sets in columns, including sets nested in | ||
| lists and user classes. Nested dictionary keys, set items, and list comparison | ||
| keys use Arrow or Polars kernels. | ||
| - Direct structural-dictionary conversion round-trips sets of logical values, | ||
| including struct fields with their own logical decoders. | ||
| - Explicit Arrow schema overrides use the requested field types and compare only | ||
| the fields stored in the target schema. A logical set column omitted by the | ||
| override is skipped, including for an empty projection. Function iteration | ||
| validates wrapped sets without sorting each output. |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| ## `src/orcapod/semantic_types/canonical_order.py` — dict and set values in canonical order | ||
|
|
||
| ### DO2 — Sets of logical elements used representation text as a fallback order | ||
| **Status:** resolved | ||
| **Severity:** medium | ||
| **Issue:** ITL-922 | ||
|
|
||
| Struct storage fell back to representation-text order, which put a field with | ||
| `10` before `2`. NaNs and distinct instances with equal declared fields could | ||
| enter storage. A scalar-stored logical type could also admit NaNs and equal | ||
| storage values. | ||
|
|
||
| **Fix:** Apply canonical order to struct-stored elements after Arrow coercion. | ||
| Sort the struct fields in declared order and use a lexicographic key for each | ||
| list field. Sort nested dict keys and set items in their own declared storage | ||
| types before comparing the enclosing elements. Check adjacent sorted values | ||
| for duplicates within each set. Multi-row table conversion encodes and sorts | ||
| each set column in one pass, including sets nested in lists and user classes. | ||
| Small sets with flat exact keys compare the coerced Arrow values without | ||
| constructing a sort table. Direct structural-dictionary reads pass Python | ||
| storage values to each logical decoder. | ||
| Function iteration checks the coerced storage keys for NaNs and duplicates | ||
| without sorting the row, including when a list or class wraps the set. | ||
| Function table assembly carries the typed source-info columns directly from | ||
| the rows so it can encode and order the payload once per column. | ||
| An explicit Arrow schema override compares its retained fields in the user | ||
| class's declared order after coercing them to their target Arrow types. | ||
| Columns omitted by an Arrow schema override are skipped during checked-set | ||
| writes, including when the override has no fields. | ||
| Explicit native writes reuse converters by Python type, even when Arrow | ||
| schema metadata changes between writes. | ||
| Sets of other logical types keep their native sort. For user-defined scalar | ||
| storage, one Arrow pass per table column rejects NaNs and duplicate stored | ||
| values. The same ordering rules apply to classes rebuilt from metadata. | ||
| The conversion boundary supplies the column name. Rebuilding sets of user | ||
| classes can change affected row hashes. |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.