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 support for RIGHT JOIN, fix an issue with wildcard aliasing #19626

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Nov 4, 2024

Examples

Establish some test frames:

import polars as pl

df1 = pl.DataFrame({
  "a": [1, 2, 3],
  "b": ["x", "y", "z"],
  "c": [100, 200, 300],
})
df2 = pl.DataFrame({
  "a": [1, 3, 2],
  "b": ["qq", "pp", "oo"],
  "c": [400, 500, 600],
})

Apply a RIGHT JOIN (new feature)...
...returning all cols from the right-most frame (bugfix):

pl.sql("""
  SELECT df2.*
  FROM df1 RIGHT JOIN df2 USING (a) ORDER BY a
""").collect()

# shape: (3, 3)
# ┌─────┬─────┬─────┐
# │ a   ┆ b   ┆ c   │
# │ --- ┆ --- ┆ --- │
# │ i64 ┆ str ┆ i64 │
# ╞═════╪═════╪═════╡
# │ 1   ┆ qq  ┆ 400 │
# │ 2   ┆ oo  ┆ 600 │
# │ 3   ┆ pp  ┆ 500 │
# └─────┴─────┴─────┘

@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 Nov 4, 2024
@alexander-beedie alexander-beedie added the A-sql Area: Polars SQL functionality label Nov 4, 2024
@alexander-beedie alexander-beedie changed the title feat: Add SQL support for RIGHT JOIN, and fix an issue with wildcard aliasing feat: Add SQL support for RIGHT JOIN, fix an issue with wildcard aliasing Nov 4, 2024
Copy link

codecov bot commented Nov 4, 2024

Codecov Report

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

Project coverage is 79.92%. Comparing base (45a9313) to head (c05a2a0).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-sql/src/context.rs 91.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #19626       +/-   ##
===========================================
+ Coverage   60.10%   79.92%   +19.81%     
===========================================
  Files        1536     1536               
  Lines      211676   211687       +11     
  Branches     2445     2445               
===========================================
+ Hits       127236   169188    +41952     
+ Misses      83885    41944    -41941     
  Partials      555      555               

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

@alexander-beedie alexander-beedie force-pushed the sql-wildcard-aliasing branch 2 times, most recently from 67e35b4 to 7969ec3 Compare November 4, 2024 14:02
@ritchie46 ritchie46 merged commit ace2e3f into pola-rs:main Nov 6, 2024
25 checks passed
@alexander-beedie alexander-beedie deleted the sql-wildcard-aliasing branch November 6, 2024 10:29
tylerriccio33 pushed a commit to tylerriccio33/polars that referenced this pull request Nov 8, 2024
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.

SQL SELECT right.* returns values from left side in JOIN query
2 participants