Skip to content

Commit 48793a5

Browse files
mattijsdpclaude
andcommitted
refactor: Derive metadata read options from read_parquet_metadata signature
Introspect pl.read_parquet_metadata's parameters instead of hard-coding the allowlist, so the forwarded options track the installed polars version rather than drifting against it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5df2685 commit 48793a5

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

dataframely/_storage/parquet.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) QuantCo 2025-2026
22
# SPDX-License-Identifier: BSD-3-Clause
33

4+
import inspect
45
from collections.abc import Iterable
56
from typing import Any
67

@@ -250,15 +251,14 @@ def scan_failure_info(
250251
return lf, serialized_rules, serialized_schema
251252

252253

254+
# `read_parquet_metadata` has no `**kwargs`, so unrecognized keys raise `TypeError`.
255+
_METADATA_READ_PARAMS = frozenset(
256+
inspect.signature(pl.read_parquet_metadata).parameters
257+
) - {"source"}
258+
259+
253260
def _metadata_read_options(kwargs: dict[str, Any]) -> dict[str, Any]:
254-
# Forward only the options that `read_parquet_metadata` accepts (it has a narrower
255-
# signature than `read_parquet`/`scan_parquet`) so the metadata read reaches the
256-
# same store as the data read.
257-
return {
258-
key: kwargs[key]
259-
for key in ("storage_options", "credential_provider", "retries")
260-
if key in kwargs
261-
}
261+
return {k: v for k, v in kwargs.items() if k in _METADATA_READ_PARAMS}
262262

263263

264264
def _read_serialized_collection(

0 commit comments

Comments
 (0)