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: Add SQL interface support for PostgreSQL dollar-quoted string literals #17940

Merged

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Jul 30, 2024

A quick coffee-break-sized PR ☕
Adds SQL support for PostgreSQL dollar-quoted string literals1.

Example

import polars as pl

pl.sql("""
  SELECT
    $$string$$ AS s1,
    $tag$another string$tag$ AS s2
""").collect()

# shape: (1, 2)
# ┌────────┬────────────────┐
# │ s1     ┆ s2             │
# │ ---    ┆ ---            │
# │ str    ┆ str            │
# ╞════════╪════════════════╡
# │ string ┆ another string │
# └────────┴────────────────┘

Footnotes

  1. https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING

@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 30, 2024
@alexander-beedie alexander-beedie added the A-sql Area: Polars SQL functionality label Jul 30, 2024
Copy link

codecov bot commented Jul 30, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.34%. Comparing base (5fc791c) to head (09d5748).
Report is 7 commits behind head on main.

Files Patch % Lines
crates/polars-sql/src/sql_expr.rs 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17940      +/-   ##
==========================================
- Coverage   80.49%   80.34%   -0.15%     
==========================================
  Files        1493     1492       -1     
  Lines      196477   196332     -145     
  Branches     2813     2813              
==========================================
- Hits       158155   157745     -410     
- Misses      37801    38066     +265     
  Partials      521      521              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexander-beedie alexander-beedie merged commit aa1950c into pola-rs:main Jul 30, 2024
28 checks passed
@alexander-beedie alexander-beedie deleted the sql-dollar-quoted-literals branch July 30, 2024 09:35
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