panel-extensions / panel-graphic-walker

A project providing a Graphic Walker Pane for use with HoloViz Panel.
https://github.com/panel-extensions/panel-graphic-walker
MIT License
32 stars 3 forks source link

Support DuckDBPyRelation kernel computations #37

Closed MarcSkovMadsen closed 2 weeks ago

MarcSkovMadsen commented 2 weeks ago

Continues from #22. So review that one first.

Addresses #10 by adding kernel_computation=True support for duckdb.duckdb.DuckDBPyRelation objects supported by narwhals.

MarcSkovMadsen commented 2 weeks ago

I first tried to see if I could use the existing pygwalker database Connector class. But this needs a connectionstring and I simply could not figure out how to get it if I only have access to the relation because the connection is created by the user outside of "my control". I've asked for help in https://github.com/duckdb/duckdb/discussions/14768.

The current approach tries to implement a custom Connector class. The key point is to be able to execute subqueries on existing relations. It can actually be done in them most simple case but not more advanced cases (see added tests). I've asked for help in https://github.com/duckdb/duckdb/discussions/14772.

An alternative approach would be to see if I could use the BaseDataFrameParser. But as far as I can see I will run into the same problems as I have now.

Any one is free to take a look. I'm currently stuck and out of ideas.

MarcSkovMadsen commented 2 weeks ago

I managed to work around the problem by requiring the users register their duckdb connections. One day we might figure out how to avoid this.

MarcSkovMadsen commented 2 weeks ago

Found the .query argument which solves the issue.