Skip to content
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

Merge sorted produces wrong result for lexical categorical #21025

Open
2 tasks done
coastalwhite opened this issue Jan 31, 2025 · 0 comments
Open
2 tasks done

Merge sorted produces wrong result for lexical categorical #21025

coastalwhite opened this issue Jan 31, 2025 · 0 comments
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@coastalwhite
Copy link
Collaborator

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import polars as pl
from polars.testing import assert_series_equal

s = pl.Series('a', ["c1", "c0"], pl.Categorical(ordering = "lexical"))

df = pl.DataFrame([s.sort()])

merge_sorted = df.lazy().merge_sorted(df.lazy(), "a").collect().get_column("a")
append_sorted = s.append(s).sort()

assert_series_equal(merge_sorted, append_sorted)

Log output

Traceback (most recent call last):
  File "/home/johndoe/Projects/polars/bug.py", line 14, in <module>
    test_merge_sorted_self_parametric(pl.Series('a', ["c1", "c0"], pl.Categorical(ordering = "lexical")))
  File "/home/johndoe/Projects/polars/bug.py", line 12, in test_merge_sorted_self_parametric
    assert_series_equal(merge_sorted, append_sorted)
  File "/home/johndoe/Projects/polars/py-polars/polars/_utils/deprecation.py", line 92, in wrapper
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/johndoe/Projects/polars/py-polars/polars/testing/asserts/series.py", line 117, in assert_series_equal
    _assert_series_values_equal(
  File "/home/johndoe/Projects/polars/py-polars/polars/testing/asserts/series.py", line 197, in _assert_series_values_equal
    raise_assertion_error(
  File "/home/johndoe/Projects/polars/py-polars/polars/testing/asserts/utils.py", line 12, in raise_assertion_error
    raise AssertionError(msg) from cause
AssertionError: Series are different (exact value mismatch)
[left]:  ['c0', 'c1', 'c0', 'c1']
[right]: ['c0', 'c0', 'c1', 'c1']

Issue description

Expected behavior

Installed versions

Replace this line with the output of pl.show_versions(). Leave the backticks in place.
@coastalwhite coastalwhite added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

1 participant