Skip to content

Commit 66e1d04

Browse files
Bug Fix: pq_file.schema.names(): TypeError: 'list' object is not callable (#1412)
* Reference attribute not callable * adding test to validate feature * fixing static checks
1 parent dc555a9 commit 66e1d04

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

awswrangler/s3/_read_parquet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ def _read_parquet_file(
483483
coerce_int96_timestamp_unit=pyarrow_args["coerce_int96_timestamp_unit"],
484484
)
485485
if validate_schema and pq_file and columns:
486-
pq_file_columns: List[str] = pq_file.schema.names()
486+
pq_file_columns: List[str] = pq_file.schema.names
487487
for column in columns:
488488
if column not in pq_file_columns:
489489
raise exceptions.InvalidArgument(f"column: {column} does not exist")

tests/test_s3_parquet.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,12 @@ def test_timezone_raw_values(path):
485485
assert df2.equals(df3)
486486

487487

488+
def test_validate_columns(path) -> None:
489+
wr.s3.to_parquet(pd.DataFrame({"a": [1], "b": [2]}), path, dataset=True)
490+
with pytest.raises(wr.exceptions.InvalidArgument):
491+
wr.s3.read_parquet(path, columns=["a", "b", "c"], validate_schema=True)
492+
493+
488494
@pytest.mark.parametrize("use_threads", [True, False, 2])
489495
def test_empty_column(path, use_threads):
490496
df = pd.DataFrame({"c0": [1, 2, 3], "c1": [None, None, None], "par": ["a", "b", "c"]})

0 commit comments

Comments
 (0)