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

scan_parquet + with_row_index + selecting only the index returns empty dataframe #18463

Closed
2 tasks done
guyrosin opened this issue Aug 29, 2024 · 0 comments · Fixed by #18520
Closed
2 tasks done

scan_parquet + with_row_index + selecting only the index returns empty dataframe #18463

guyrosin opened this issue Aug 29, 2024 · 0 comments · Fixed by #18520
Assignees
Labels
A-io-parquet Area: reading/writing Parquet files accepted Ready for implementation bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@guyrosin
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 tempfile
from pathlib import Path

import polars as pl

with tempfile.TemporaryDirectory() as d:
    path = Path(d) / "test.parquet"
    pl.DataFrame({"A": [1, 4], "B": [2, 5]}).write_parquet(path)
    df = pl.scan_parquet(path).with_row_index()

    print(df.collect().select("index"))  # OK
    print(df.select("index", "A").collect())  # OK

    print(df.select("index").collect())  # empty

Output:

shape: (2, 1)
┌───────┐
│ index │
│ ---   │
│ u32   │
╞═══════╡
│ 0     │
│ 1     │
└───────┘
shape: (2, 2)
┌───────┬─────┐
│ index ┆ A   │
│ ---   ┆ --- │
│ u32   ┆ i64 │
╞═══════╪═════╡
│ 0     ┆ 1   │
│ 1     ┆ 4   │
└───────┴─────┘
shape: (0, 1)
┌───────┐
│ index │
│ ---   │
│ u32   │
╞═══════╡
└───────┘

Log output

No response

Issue description

The index column cannot be selected alone after a scan_parquet operation.
This behavior doesn't occur for scan_csv.

Expected behavior

The index column should be returned, as it does for a DataFrame

Installed versions

--------Version info---------
Polars:              1.6.0
Index type:          UInt32
Platform:            Linux-6.5.0-1024-aws-x86_64-with-glibc2.35
Python:              3.11.9 (main, Jul 13 2024, 23:44:43) [Clang 17.0.6 ]

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               5.4.1
cloudpickle          3.0.0
connectorx           <not installed>
deltalake            <not installed>
fastexcel            0.11.6
fsspec               2024.6.1
gevent               <not installed>
great_tables         <not installed>
matplotlib           3.9.2
nest_asyncio         1.6.0
numpy                1.26.4
openpyxl             <not installed>
pandas               2.2.2
pyarrow              17.0.0
pydantic             2.8.2
pyiceberg            <not installed>
sqlalchemy           2.0.32
torch                2.2.2+cu121
xlsx2csv             0.8.3
xlsxwriter           <not installed>
@guyrosin guyrosin added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Aug 29, 2024
@nameexhaustion nameexhaustion added accepted Ready for implementation P-low Priority: low A-io-parquet Area: reading/writing Parquet files and removed needs triage Awaiting prioritization by a maintainer labels Aug 30, 2024
@coastalwhite coastalwhite self-assigned this Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io-parquet Area: reading/writing Parquet files accepted Ready for implementation bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants