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

Cannot use with_context with output of scan_* functions #9006

Closed
2 tasks done
erinov1 opened this issue May 23, 2023 · 2 comments
Closed
2 tasks done

Cannot use with_context with output of scan_* functions #9006

erinov1 opened this issue May 23, 2023 · 2 comments
Labels
bug Something isn't working python Related to Python Polars

Comments

@erinov1
Copy link

erinov1 commented May 23, 2023

Polars version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of Polars.

Issue description

The following raises an error:

import polars as pl

df1 = pl.LazyFrame({"A": [1]})
pl.DataFrame({"B": [1]}).write_csv("test.csv")

# This fails with PanicException: called `Option::unwrap()` on a `None` value
df1.with_context(pl.scan_csv("test.csv")).collect()

# This succeeds
df1.with_context(pl.scan_csv("test.csv").collect().lazy()).collect()

# Reversing the order also succeeds 
pl.scan_csv("test.csv").with_context(df1).collect()

The same error arises for scan_parquet and scan_ipc.

Reproducible example

import polars as pl

df1 = pl.LazyFrame({"A": [1]})
pl.DataFrame({"B": [1]}).write_csv("test.csv")

# This fails with PanicException: called `Option::unwrap()` on a `None` value
df1.with_context(pl.scan_csv("test.csv")).collect()

Expected behavior

Code should run regardless of the source of the lazyframe.

Installed versions

--------Version info---------
Polars:      0.17.15
Index type:  UInt32
Platform:    macOS-13.2-arm64-arm-64bit
Python:      3.11.1 (main, Feb  8 2023, 16:32:14) [Clang 14.0.0 (clang-1400.0.29.202)]

----Optional dependencies----
numpy:       1.23.5
pandas:      1.5.3
pyarrow:     11.0.0
connectorx:  <not installed>
deltalake:   <not installed>
fsspec:      2023.1.0
matplotlib:  3.7.0
xlsx2csv:    <not installed>
xlsxwriter:  <not installed>
@erinov1 erinov1 added bug Something isn't working python Related to Python Polars labels May 23, 2023
@daviskirk
Copy link
Contributor

I have this as well, interestingly only for polars > 0.19.6. Since this issue is older I'm not sure if it's really the same issue, or if #12416 also came up in newer versions.

@stinodego stinodego added the needs triage Awaiting prioritization by a maintainer label Jan 13, 2024
@stinodego
Copy link
Member

LazyFrame.with_context will be deprecated with the release of 1.0.0 (#16860). We will not fix any bugs associated with it.

Please use pl.concat(..., how="horizontal") instead to combine LazyFrames into a single context.

@stinodego stinodego closed this as not planned Won't fix, can't repro, duplicate, stale Jun 10, 2024
@stinodego stinodego removed the needs triage Awaiting prioritization by a maintainer label Jun 10, 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 python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

3 participants