Skip to content

Python: Allow replacement scans on pyrelations, move to BoxRenderer and use pending query API for relations#5962

Merged
Mytherin merged 11 commits intoduckdb:masterfrom
Mytherin:pythonimprovements
Jan 24, 2023
Merged

Python: Allow replacement scans on pyrelations, move to BoxRenderer and use pending query API for relations#5962
Mytherin merged 11 commits intoduckdb:masterfrom
Mytherin:pythonimprovements

Conversation

@Mytherin
Copy link
Collaborator

This PR makes several improvements to the Python Relational API:

  • Move to BoxRenderer for relation objects
  • Allows querying relation objects using replacement scans, e.g. this now works:
lineitem = duckdb.query('from lineitem.parquet');
res = duckdb.query('select l_returnflag, sum(l_extendedprice) from lineitem group by all')
print(res)
┌──────────────┬──────────────────────┐
│ l_returnflagsum(l_extendedprice) │
│   varchardecimal(38,2)     │
├──────────────┼──────────────────────┤
│ A56586554400.73 │
│ N116422715119.57 │
│ R56568041380.90 │
└──────────────┴──────────────────────┘
  • Move to using pending query results, so execution of relations can be interrupted
  • Add a cache for the str representation of relation objects

@Mytherin Mytherin requested a review from Tishj January 23, 2023 08:53
Copy link
Contributor

@Mause Mause left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks 😅

Thanks @Mause

Co-authored-by: Elliana May <me@mause.me>
Copy link
Contributor

@Tishj Tishj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, great piece of functionality and seems like this was relatively low hanging fruit.
That being said it was invisible to me haha

I had one final comment regarding the removal of the GIL unlock to print the progress bar.
Sadly we dont/cant have Jupyter tests, I'm curious if this might break something there

if (!success) {
return GetError() + "\n";
}
if (!collection) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not want to throw an exception here instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general results should not throw exceptions because they might be used in places where those are unexpected.

@Mytherin Mytherin merged commit b7b7ea6 into duckdb:master Jan 24, 2023
@Mytherin Mytherin deleted the pythonimprovements branch February 16, 2023 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants