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(python): add sql() and show() convenience method to QueryBuilder #3100

Merged

Conversation

DevChrisCross
Copy link
Contributor

@DevChrisCross DevChrisCross commented Jan 3, 2025

Description

Adds user friendly methods, namely sql() and show() to the QueryBuilder

Related Issue(s)

Documentation

@github-actions github-actions bot added the binding/python Issues for the Python package label Jan 3, 2025
Copy link

github-actions bot commented Jan 3, 2025

ACTION NEEDED

delta-rs follows the Conventional Commits specification for release automation.

The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification.

@DevChrisCross DevChrisCross changed the title Added sql() and show() convenience method to QueryBuilder feat(python): add sql() and show() convenience method to QueryBuilder Jan 3, 2025
@DevChrisCross DevChrisCross force-pushed the feat/sql-and-show-convenience-methods branch 2 times, most recently from ac92f90 to 9ce60c5 Compare January 3, 2025 20:01
Copy link

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.51%. Comparing base (6430151) to head (a420c33).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3100      +/-   ##
==========================================
- Coverage   72.52%   72.51%   -0.01%     
==========================================
  Files         128      128              
  Lines       41201    41201              
  Branches    41201    41201              
==========================================
- Hits        29882    29878       -4     
- Misses       9408     9412       +4     
  Partials     1911     1911              

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

@ion-elgreco
Copy link
Collaborator

@DevChrisCross the .SQL() should rather give an object that's lazy executed, similar to duckdb's python API:

https://duckdb.org/docs/api/python/reference/

You can see the method .SQL() and .show() there

@djouallah
Copy link

for what is worth it, instead of qb.show().execute(query)
it should be
qb.execute(query).show()

@DevChrisCross DevChrisCross force-pushed the feat/sql-and-show-convenience-methods branch from 17ad1cf to a3bc9ef Compare January 4, 2025 08:41
@DevChrisCross
Copy link
Contributor Author

I've introduced a QueryResult class to accommodate the lazy execution, and in turn, introduced fetchall() as well, let me know if it is okay @ion-elgreco @djouallah

@djouallah
Copy link

do you mind adding qb.sql(query).show() too please

@DevChrisCross
Copy link
Contributor Author

do you mind adding qb.sql(query).show() too please

Ah yes, that was already added as well :)

@DevChrisCross DevChrisCross force-pushed the feat/sql-and-show-convenience-methods branch 2 times, most recently from a518e32 to fd56cf4 Compare January 4, 2025 17:15
@ion-elgreco
Copy link
Collaborator

@DevChrisCross looks good, perhaps also add a to_arrow() which returns a pyarrow table and to_pandas() on it as well : )

@rtyler
Copy link
Member

rtyler commented Jan 4, 2025

I am squashing this and will then merge, I love seeing more improvements here 😄

@rtyler rtyler force-pushed the feat/sql-and-show-convenience-methods branch from fd56cf4 to a420c33 Compare January 4, 2025 22:50
@rtyler rtyler enabled auto-merge January 4, 2025 22:50
@rtyler rtyler added this to the v0.23 milestone Jan 4, 2025
@rtyler rtyler added this pull request to the merge queue Jan 4, 2025
Merged via the queue into delta-io:main with commit 3eef27b Jan 4, 2025
24 checks passed
@DevChrisCross
Copy link
Contributor Author

@rtyler Oh it was merged already? I was initially trying to accommodate comments @ion-elgreco regarding the to_arrow and to_pandas methods 😅 Is it still needed?

@rtyler
Copy link
Member

rtyler commented Jan 5, 2025

@DevChrisCross I think those are good ideas to add in additional pull requests 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding/python Issues for the Python package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request : user friendly methods for Querybuilder , show and sql
4 participants