-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 3154 from_parquet should be able to read partial columns (#3156)
* feat: 3154 - Adding unit test and fix * Taking this opportunity to fix an issue with 2772 test This had been bugging me, and with a better understanding now I can improve the unit tests. Mostly for future readability and correctness. * Removing commented-out test return value --------- Co-authored-by: Ianna Osborne <[email protected]>
- Loading branch information
1 parent
6f688e9
commit 03f6169
Showing
3 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE | ||
# ruff: noqa: E402 | ||
|
||
from __future__ import annotations | ||
|
||
import os | ||
|
||
import pytest | ||
|
||
import awkward as ak | ||
|
||
pa = pytest.importorskip("pyarrow") | ||
pq = pytest.importorskip("pyarrow.parquet") | ||
|
||
|
||
def test_parquet_subcolumn_select(tmp_path): | ||
ak_tbl = ak.Array( | ||
{ | ||
"a": [ | ||
{"lbl": "item 1", "idx": 11, "ids": [1, 2, 3]}, | ||
{"lbl": "item 2", "idx": 12, "ids": [51, 52]}, | ||
{"lbl": "item 3", "idx": 13, "ids": [61, 62, 63, 64]}, | ||
], | ||
"b": [ | ||
[[111, 112], [121, 122]], | ||
[[211, 212], [221, 222]], | ||
[[311, 312], [321, 322]], | ||
], | ||
} | ||
) | ||
parquet_file = os.path.join(tmp_path, "test_3514.parquet") | ||
ak.to_parquet(ak_tbl, parquet_file) | ||
|
||
selection = ak.from_parquet(parquet_file, columns=["a.ids", "b"]) | ||
assert selection["a"].to_list() == [ | ||
{"ids": [1, 2, 3]}, | ||
{"ids": [51, 52]}, | ||
{"ids": [61, 62, 63, 64]}, | ||
] | ||
assert selection["b"].to_list() == ak_tbl["b"].to_list() |