Skip to content

Commit

Permalink
rebase on the other pr
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed Sep 13, 2024
1 parent 06e6500 commit 9ed44f2
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions hvplot/duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@

def patch(name='hvplot', interactive='interactive', extension='bokeh', logo=False):
from hvplot.plotting.core import hvPlotTabularDuckDB
from . import post_patch
from . import post_patch, _module_extensions

try:
import duckdb
except ImportError:
raise ImportError(
'Could not patch plotting API onto DuckDB. DuckDB could not be imported.'
)
if 'hvplot.duckdb' not in _module_extensions:
try:
import duckdb
except ImportError:
raise ImportError(
'Could not patch plotting API onto DuckDB. DuckDB could not be imported.'
)

# Patching for DuckDBPyRelation and DuckDBPyConnection
_patch_duckdb_plot = lambda self: hvPlotTabularDuckDB(self) # noqa: E731
_patch_duckdb_plot.__doc__ = hvPlotTabularDuckDB.__call__.__doc__
plot_prop_duckdb = property(_patch_duckdb_plot)
setattr(duckdb.DuckDBPyRelation, name, plot_prop_duckdb)
setattr(duckdb.DuckDBPyConnection, name, plot_prop_duckdb)
# Patching for DuckDBPyRelation and DuckDBPyConnection
_patch_duckdb_plot = lambda self: hvPlotTabularDuckDB(self) # noqa: E731
_patch_duckdb_plot.__doc__ = hvPlotTabularDuckDB.__call__.__doc__
plot_prop_duckdb = property(_patch_duckdb_plot)
setattr(duckdb.DuckDBPyRelation, name, plot_prop_duckdb)
setattr(duckdb.DuckDBPyConnection, name, plot_prop_duckdb)
_module_extensions.add('hvplot.duckdb')

post_patch(extension, logo)

Expand Down

0 comments on commit 9ed44f2

Please sign in to comment.