Skip to content

bug: ExtractHour from time is not mapped #519

@Tishj

Description

@Tishj

What happened?

I am not sure if I'm just holding it wrong, but I am trying to test some substrait roundtripping and wanted to use Ibis to generate some json serialized substrait plans.

I ran the following code:

import ibis_substrait
from ibis_substrait.compiler.core import SubstraitCompiler
import ibis.expr.datatypes as dt

compiler = SubstraitCompiler()

t = ibis.table([("d", dt.time)], name="dates")
expr = t[getattr(t.d, "hour")()]

from google.protobuf import json_format

proto = compiler.compile(expr)

json_plan = json_format.MessageToJson(proto)
print(json_plan)

And I ran into an exception:

  File "/opt/homebrew/lib/python3.10/site-packages/ibis_substrait/compiler/core.py", line 75, in function_id
    op_name = IBIS_SUBSTRAIT_OP_MAPPING[op_type.__name__]
KeyError: 'ExtractHour'

What version of ibis-substrait are you using?

>>> ibis_substrait.__version__
'2.22.0'

What substrait consumer(s) are you using, if any?

Relevant log output

Traceback (most recent call last):
  File "ibis_extract.py", line 23, in <module>
    proto = compiler.compile(expr)
  File "/opt/homebrew/lib/python3.10/site-packages/ibis_substrait/compiler/core.py", line 96, in compile
    input=translate(expr.op(), expr=expr, compiler=self, **kwargs),
  File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/functools.py", line 889, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/opt/homebrew/lib/python3.10/site-packages/ibis_substrait/compiler/translate.py", line 824, in selection
    expressions=[
  File "/opt/homebrew/lib/python3.10/site-packages/ibis_substrait/compiler/translate.py", line 825, in <listcomp>
    translate(
  File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/functools.py", line 889, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/opt/homebrew/lib/python3.10/site-packages/ibis_substrait/compiler/translate.py", line 236, in _expr
    return translate(expr.op(), expr, compiler=compiler, **kwargs)
  File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/functools.py", line 889, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/opt/homebrew/lib/python3.10/site-packages/ibis_substrait/compiler/translate.py", line 524, in value_op
    function_reference=compiler.function_id(expr=expr),
  File "/opt/homebrew/lib/python3.10/site-packages/ibis_substrait/compiler/core.py", line 75, in function_id
    op_name = IBIS_SUBSTRAIT_OP_MAPPING[op_type.__name__]
KeyError: 'ExtractHour'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions