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

feat(rust,python,cli): add LEFT string function for SQL #9836

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

alexander-beedie
Copy link
Collaborator

Adds SQL support for the string left function, and associated unit tests.

Example

import polars as pl
df = pl.DataFrame({
    "scol": ["abcde", "abc", "a", None],
})
with pl.SQLContext( frame=df ) as ctx:
    res = ctx.execute(
        'SELECT scol, LEFT(scol,2) AS "scol:left2" FROM frame',
    ).collect()
    
# shape: (4, 2)
# ┌───────┬────────────┐
# │ scol  ┆ scol:left2 │
# │ ---   ┆ ---        │
# │ str   ┆ str        │
# ╞═══════╪════════════╡
# │ abcde ┆ ab         │
# │ abc   ┆ ab         │
# │ a     ┆ a          │
# │ null  ┆ null       │
# └───────┴────────────┘

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Jul 12, 2023
@alexander-beedie alexander-beedie added the A-sql Area: Polars SQL functionality label Jul 12, 2023
@alexander-beedie alexander-beedie merged commit 4e1bd53 into pola-rs:main Jul 12, 2023
@alexander-beedie alexander-beedie deleted the sql-string-left branch July 12, 2023 15:59
c-peters pushed a commit to c-peters/polars that referenced this pull request Jul 14, 2023
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 enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants