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

Error on calling polars.Expr.meta.tree_format with expressions from list of columns #15278

Open
2 tasks done
Aamlsmfc opened this issue Mar 25, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@Aamlsmfc
Copy link

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import polars
polars.col("a", "b").meta.tree_format()

Log output

thread 'ipython' panicked at crates/polars-plan/src/logical_plan/conversion.rs:160:33:
no `columns` expected at this point
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---------------------------------------------------------------------------
PanicException                            Traceback (most recent call last)
<ipython-input-2-71d2003df3e0> in <module>
----> 1 polars.col("a", "b").meta.tree_format()

../lib/python3.8/site-packages/polars/_utils/deprecation.py in wrapper(*args, **kwargs)
    224             if len(args) > num_allowed_args:
    225                 issue_deprecation_warning(msg, version=version)
--> 226             return function(*args, **kwargs)
    227
    228         wrapper.__signature__ = new_sig  # type: ignore[attr-defined]

../lib/python3.8/site-packages/polars/expr/meta.py in tree_format(self, return_as_string)
    308         >>> e.meta.tree_format(return_as_string=True)  # doctest: +SKIP
    309         """
--> 310         s = self._pyexpr.meta_tree_format()
    311         if return_as_string:
    312             return s

PanicException: no `columns` expected at this point

Issue description

The polars.expr.meta interface does not fully support expressions for functions taking as input multiple columns. Thus, using meta functions on expression such as polars.col(["a", "b"]).some_function() often throws errors.

Here is a small example that throws an error.

Expected behavior

One would have expected an output like the one below:

        0
   ┌─────────────────────
   │
   │  ╭──────────────╮
 0 │  │ cols([a, b]) │
   │  ╰──────────────╯

Installed versions

--------Version info---------
Polars:               0.20.16
Index type:           UInt32
Platform:             Linux-3.10.0-1160.el7.x86_64-x86_64-with-glibc2.2.5
Python:               3.8.16 (default, Apr 26 2023, 19:39:47)
[GCC 9.3.1 20200408 (Red Hat 9.3.1-2)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           0.3.2
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
hvplot:               0.9.2
matplotlib:           3.7.1
numpy:                1.23.5
openpyxl:             <not installed>
pandas:               1.5.3
pyarrow:              15.0.0
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           1.4.46
xlsx2csv:             <not installed>
xlsxwriter:           3.1.2
@Aamlsmfc Aamlsmfc added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

1 participant