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

fix(rust,python,cli): handle unary operators applied to numbers used in SQL IN clauses #11574

Merged

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Oct 6, 2023

Closes #8890.

Example

import polars as pl

df = pl.DataFrame({
    "aa": [-2, -1, 1, 2],
    "bb": ["w","x","y","z"],
})
with pl.SQLContext( frame=df ) as ctx:
    res = ctx.execute("SELECT * FROM frame WHERE aa IN (-3,-1,+2,+4)")

Before

ComputeError: SQL expression UnaryOp 
  { op: Minus, expr: Value(Number("3", false)) } is not yet supported

After

shape: (2, 2)
┌─────┬─────┐
│ aa  ┆ bb  │
│ --- ┆ --- │
│ i64 ┆ str │
╞═════╪═════╡
│ -1  ┆ x   │
│ 2   ┆ z   │
└─────┴─────┘

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Oct 6, 2023
@alexander-beedie alexander-beedie changed the title fix(rust,python,cli): handle unary minus applied to numbers used in SQL IN clauses fix(rust,python,cli): handle unary operators applied to numbers used in SQL IN clauses Oct 6, 2023
@alexander-beedie alexander-beedie added the A-sql Area: Polars SQL functionality label Oct 6, 2023
@alexander-beedie alexander-beedie marked this pull request as draft October 6, 2023 16:17
@alexander-beedie alexander-beedie force-pushed the fix-unary-minus-sql-in-values branch 2 times, most recently from 467cfc0 to 6b6222f Compare October 6, 2023 16:28
@alexander-beedie alexander-beedie marked this pull request as ready for review October 6, 2023 16:28
@alexander-beedie alexander-beedie force-pushed the fix-unary-minus-sql-in-values branch from 6b6222f to c3d040a Compare October 6, 2023 16:30
@ritchie46 ritchie46 merged commit 4d0e54a into pola-rs:main Oct 7, 2023
24 checks passed
@alexander-beedie alexander-beedie deleted the fix-unary-minus-sql-in-values branch October 7, 2023 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql Area: Polars SQL functionality fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unary minus operator doesn't work with IN condition in SQLContext
3 participants