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

ibis.common.exceptions.OperationNotDefinedError: No translation rule for <class 'ibis.expr.operations.generic.RowID'> #5526

Open
MarcSkovMadsen opened this issue Nov 28, 2022 · 0 comments · May be fixed by #5527
Labels
type: bug Something isn't correct or isn't working

Comments

@MarcSkovMadsen
Copy link
Collaborator

I'm trying to add a DuckDB user guide to hvPlot. When trying to create a bar plot using hvplot I get the error below. There is no issue with the matplotlib or bokeh backend.

import duckdb
import ibis
import pandas as pd

from pathlib import Path
import hvplot.ibis

hvplot.extension("plotly")

DUCKDB_PATH = "DuckDB.db"

if not Path(DUCKDB_PATH).exists():
    pandas_df = pd.DataFrame(
        {
            "actual": [100, 150, 125, 140, 145, 135, 123],
            "forecast": [90, 160, 125, 150, 141, 141, 120],
            "numerical": [1.1, 1.9, 3.2, 3.8, 4.3, 5.0, 5.5],
            "date": pd.date_range("2022-01-03", "2022-01-09"),
            "string": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
    )
    duckdb_con = duckdb.connect(DUCKDB_PATH)
    duckdb_con.execute("CREATE TABLE df AS SELECT * FROM pandas_df")

ibis.options.sql.default_limit = None

db = ibis.duckdb.connect(DUCKDB_PATH)

table = db.table("df")

plot = table.hvplot.bar(x="string", y="actual", line_width=2, alpha=0.7)

import panel as pn
pn.panel(plot).servable()

image

Traceback (most recent call last):
  File "C:\repos\private\hvplot\.venv\lib\site-packages\bokeh\application\handlers\code_runner.py", line 231, in run
    exec(self._code, module.__dict__)
  File "C:\repos\private\hvplot\script2.py", line 34, in <module>
    pn.panel(plot).servable()
  File "C:\repos\private\hvplot\.venv\lib\site-packages\panel\viewable.py", line 379, in servable
    self.server_doc(title=title, location=location) # type: ignore
  File "C:\repos\private\hvplot\.venv\lib\site-packages\panel\viewable.py", line 871, in server_doc
    model = self.get_root(doc)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\panel\pane\base.py", line 316, in get_root
    root = self.layout._get_model(doc, comm=comm)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\panel\layout\base.py", line 146, in _get_model
    objects = self._get_objects(model, [], doc, root, comm)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\panel\layout\base.py", line 131, in _get_objects
    child = pane._get_model(doc, root, model, comm)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\panel\pane\holoviews.py", line 265, in _get_model
    plot = self._render(doc, comm, root)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\panel\pane\holoviews.py", line 342, in _render
    return renderer.get_plot(self.object, **kwargs)
  File "c:\repos\private\holoviews\holoviews\plotting\renderer.py", line 240, in get_plot
    plot.update(init_key)
  File "c:\repos\private\holoviews\holoviews\plotting\plot.py", line 948, in update
    return self.initialize_plot()
  File "c:\repos\private\holoviews\holoviews\plotting\plotly\element.py", line 124, in initialize_plot
    fig = self.generate_plot(self.keys[-1], ranges, is_geo=is_geo)
  File "c:\repos\private\holoviews\holoviews\plotting\plotly\element.py", line 179, in generate_plot
    data = self.get_data(element, ranges, style, is_geo=is_geo)
  File "c:\repos\private\holoviews\holoviews\plotting\plotly\chart.py", line 256, in get_data
    values.append(sel.iloc[0, 1] if len(sel) else 0)
  File "c:\repos\private\holoviews\holoviews\core\data\interface.py", line 34, in __getitem__
    res = self._perform_getitem(self.dataset, index)
  File "c:\repos\private\holoviews\holoviews\core\data\interface.py", line 78, in _perform_getitem
    data = dataset.interface.iloc(dataset, (rows, cols))
  File "c:\repos\private\holoviews\holoviews\core\data\ibis.py", line 230, in iloc
    data.filter(data.hv_row_id__ == rows)[columns]
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\expr\types\core.py", line 291, in execute
    return self._find_backend(use_default=True).execute(
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\__init__.py", line 182, in execute
    sql = query_ast.compile()
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\base.py", line 40, in compile
    compiled_queries = [q.compile() for q in self.queries]
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\base.py", line 40, in <listcomp>
    compiled_queries = [q.compile() for q in self.queries]
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 183, in compile
    frag = self._compile_table_set()
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 210, in _compile_table_set
    result = helper.get_result()
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 40, in get_result
    self.join_tables.append(self._format_table(self.expr))
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 140, in _format_table
    result = ctx.get_compiled_expr(expr)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\translator.py", line 82, in get_compiled_expr
    result = self._compile_subquery(expr)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\translator.py", line 39, in _compile_subquery
    return self._to_sql(expr, sub_ctx)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\translator.py", line 42, in _to_sql
    return self.compiler.to_sql(expr, ctx)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 419, in to_sql
    return query.compile()
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 183, in compile
    frag = self._compile_table_set()
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 210, in _compile_table_set
    result = helper.get_result()
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 40, in get_result
    self.join_tables.append(self._format_table(self.expr))
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 140, in _format_table
    result = ctx.get_compiled_expr(expr)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\translator.py", line 82, in get_compiled_expr
    result = self._compile_subquery(expr)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\translator.py", line 39, in _compile_subquery
    return self._to_sql(expr, sub_ctx)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\translator.py", line 42, in _to_sql
    return self.compiler.to_sql(expr, ctx)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 419, in to_sql
    return query.compile()
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 193, in compile
    frag = step(frag)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\query_builder.py", line 223, in _add_select
    arg = self._translate(expr, named=True)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\query_builder.py", line 253, in _translate
    return translator.get_result()
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\translator.py", line 221, in get_result
    translated = self.translate(self.expr)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\translator.py", line 256, in translate
    return formatter(self, expr)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\registry.py", line 228, in _alias
    return t.translate(op.arg)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\translator.py", line 256, in translate
    return formatter(self, expr)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\registry.py", line 58, in formatter
    return _varargs_call(sa_func, t, expr.op().args)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\alchemy\registry.py", line 66, in _varargs_call
    arg = t.translate(raw_arg)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\base\sql\compiler\translator.py", line 258, in translate
    raise com.OperationNotDefinedError(
ibis.common.exceptions.OperationNotDefinedError: No translation rule for <class 'ibis.expr.operations.generic.RowID'>`
@MarcSkovMadsen MarcSkovMadsen added the type: bug Something isn't correct or isn't working label Nov 28, 2022
@MarcSkovMadsen MarcSkovMadsen linked a pull request Nov 28, 2022 that will close this issue
@MarcSkovMadsen MarcSkovMadsen linked a pull request Nov 28, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant