polars icon indicating copy to clipboard operation
polars copied to clipboard

Import error when using scan_delta

Open dominikpeter opened this issue 2 years ago • 5 comments

Polars version checks

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

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

Issue description

I get the following import error while using polars with the new scan_delta method:

AttributeError: module 'pyarrow' has no attribute 'fs'

Reproducible example

import polars as pl
df = pl.scan_delta("/data/nytaxi")
print(df)

Expected behavior

No import error

Installed versions

---Version info--- Polars: 0.15.4 Index type: UInt32 Platform: macOS-13.0.1-arm64-arm-64bit Python: 3.10.8 (v3.10.8:aaaf517424, Oct 11 2022, 10:14:40) [Clang 13.0.0 (clang-1300.0.29.30)] ---Optional dependencies--- pyarrow: 10.0.1 pandas: numpy: 1.23.5 fsspec: 2022.11.0 connectorx: xlsx2csv: matplotlib:

dominikpeter avatar Dec 12 '22 18:12 dominikpeter

@chitralverma could you take a look at this one?

ritchie46 avatar Dec 12 '22 19:12 ritchie46

Let me check it out today.

chitralverma avatar Dec 13 '22 01:12 chitralverma

@ritchie46 , I checked this and it seems that this is coming because I imported a sub module from the lazily loaded pyarrow, see here. I believe I will have to switch this with the below or do you recommend so other better way to lazily import sub modules also?

from pyarrow import fs as pa_fs
raw_filesystem, normalized_path = pa_fs.FileSystem.from_uri(table_uri)

Surprisingly this was not not caught in the unit tests for some reason.

chitralverma avatar Dec 13 '22 10:12 chitralverma

@dominikpeter this issue will also happen for read_delta

chitralverma avatar Dec 13 '22 10:12 chitralverma

er way to lazily import sub modules als

Can we import the needed pyarrow submodules within the function itself? That should prevent all issues related to lazy imports.

ritchie46 avatar Dec 13 '22 10:12 ritchie46