Skip to content

bug: can't execute map<array, anything> #8604

Open
@NickCrews

Description

@NickCrews

What happened?

import ibis

ibis.options.interactive = True
ibis.options.repr.interactive.max_depth = 5


t = ibis.memtable(
    {
        "keys": [
            [[1, 2], [3]],
            [[4, 5]],
        ],
        "vals": [
            ["a", "b"],
            ["b"],
        ],
    },
)
ibis.map(t.keys, t.vals)
# I want a map<array, string>
# {[1, 2]: "a", [3]: "b"}
# {[4, 5]: "b"}

What version of ibis are you using?

main

What backend(s) are you using, if any?

No response

Relevant log output

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/code/scg/atlas/.venv/lib/python3.11/site-packages/IPython/core/formatters.py:708, in PlainTextFormatter.__call__(self, obj)
    701 stream = StringIO()
    702 printer = pretty.RepresentationPrinter(stream, self.verbose,
    703     self.max_width, self.newline,
    704     max_seq_length=self.max_seq_length,
    705     singleton_pprinters=self.singleton_printers,
    706     type_pprinters=self.type_printers,
    707     deferred_pprinters=self.deferred_printers)
--> 708 printer.pretty(obj)
    709 printer.flush()
    710 return stream.getvalue()

File ~/code/scg/atlas/.venv/lib/python3.11/site-packages/IPython/lib/pretty.py:410, in RepresentationPrinter.pretty(self, obj)
    407                         return meth(obj, self, cycle)
    408                 if cls is not object \
    409                         and callable(cls.__dict__.get('__repr__')):
--> 410                     return _repr_pprint(obj, self, cycle)
    412     return _default_pprint(obj, self, cycle)
    413 finally:

File ~/code/scg/atlas/.venv/lib/python3.11/site-packages/IPython/lib/pretty.py:778, in _repr_pprint(obj, p, cycle)
    776 """A pprint that just redirects to the normal repr function."""
    777 # Find newlines and replace them with p.break_()
--> 778 output = repr(obj)
    779 lines = output.splitlines()
    780 with p.group():

File ~/code/ibis/ibis/expr/types/core.py:86, in Expr.__repr__(self)
     84 with simple_console.capture() as capture:
     85     try:
---> 86         simple_console.print(self)
     87     except TranslationError as e:
     88         lines = [
     89             "Translation to backend failed",
     90             f"Error message: {e!r}",
     91             "Expression repr follows:",
     92             self._repr(),
     93         ]

File ~/code/scg/atlas/.venv/lib/python3.11/site-packages/rich/console.py:1700, in Console.print(self, sep, end, style, justify, overflow, no_wrap, emoji, markup, highlight, width, height, crop, soft_wrap, new_line_start, *objects)
   1698 if style is None:
   1699     for renderable in renderables:
-> 1700         extend(render(renderable, render_options))
   1701 else:
   1702     for renderable in renderables:

File ~/code/scg/atlas/.venv/lib/python3.11/site-packages/rich/console.py:1332, in Console.render(self, renderable, options)
   1330 _Segment = Segment
   1331 _options = _options.reset_height()
-> 1332 for render_output in iter_render:
   1333     if isinstance(render_output, _Segment):
   1334         yield render_output

File ~/code/scg/atlas/.venv/lib/python3.11/site-packages/rich/console.py:1312, in Console.render(self, renderable, options)
   1310 renderable = rich_cast(renderable)
   1311 if hasattr(renderable, "__rich_console__") and not isclass(renderable):
-> 1312     render_iterable = renderable.__rich_console__(self, _options)  # type: ignore[union-attr]
   1313 elif isinstance(renderable, str):
   1314     text_renderable = self.render_str(
   1315         renderable, highlight=_options.highlight, markup=_options.markup
   1316     )

File ~/code/ibis/ibis/expr/types/core.py:58, in Expr.__rich_console__(self, console, options)
     55     from rich.text import Text
     57     return console.render(Text(self._repr()), options=options)
---> 58 return self.__interactive_rich_console__(console, options)

File ~/code/ibis/ibis/expr/types/relations.py:531, in Table.__interactive_rich_console__(self, console, options)
    515 except Exception as e:
    516     # In IPython exceptions inside of _repr_mimebundle_ are swallowed to
    517     # allow calling several display functions and choosing to display
   (...)
    528     #
    529     # This restriction is only present in IPython, not in other REPLs.
    530     console.print_exception()
--> 531     raise e
    532 return console.render(table, options=options)

File ~/code/ibis/ibis/expr/types/relations.py:514, in Table.__interactive_rich_console__(self, console, options)
    511     width = options.max_width
    513 try:
--> 514     table = to_rich_table(self, width)
    515 except Exception as e:
    516     # In IPython exceptions inside of _repr_mimebundle_ are swallowed to
    517     # allow calling several display functions and choosing to display
   (...)
    528     #
    529     # This restriction is only present in IPython, not in other REPLs.
    530     console.print_exception()

File ~/code/ibis/ibis/expr/types/pretty.py:274, in to_rich_table(table, console_width)
    272 remaining = console_width - 1  # 1 char for left boundary
    273 for name, dtype in table.schema().items():
--> 274     formatted, min_width, max_width = format_column(
    275         dtype, result[name].to_pylist()[:nrows]
    276     )
    277     dtype_str = format_dtype(dtype)
    278     if ibis.options.repr.interactive.show_types and not isinstance(
    279         dtype, (dt.Struct, dt.Map, dt.Array)
    280     ):
    281         # Don't truncate non-nested dtypes

File ~/code/ibis/ibis/expr/types/pretty.py:202, in format_column(dtype, values)
    200 nonnull = [v for v in values if not isnull(v)]
    201 if nonnull:
--> 202     formatted = format_values(dtype, nonnull)
    203     next_f = iter(formatted).__next__
    204     out = [null_str if isnull(v) else next_f() for v in values]

File ~/.pyenv/versions/3.11.6/lib/python3.11/functools.py:909, in singledispatch.<locals>.wrapper(*args, **kw)
    905 if not args:
    906     raise TypeError(f'{funcname} requires at least '
    907                     '1 positional argument')
--> 909 return dispatch(args[0].__class__)(*args, **kw)

File ~/code/ibis/ibis/expr/types/pretty.py:41, in _(dtype, values)
     39 @format_values.register(dt.Map)
     40 def _(dtype, values):
---> 41     return _format_nested([None if v is None else dict(v) for v in values])

File ~/code/ibis/ibis/expr/types/pretty.py:41, in <listcomp>(.0)
     39 @format_values.register(dt.Map)
     40 def _(dtype, values):
---> 41     return _format_nested([None if v is None else dict(v) for v in values])

TypeError: unhashable type: 'list'

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior inside of ibisdatatypesIssues relating to ibis's datatypes (under `ibis.expr.datatypes`)

    Type

    No type

    Projects

    Status

    backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions