Skip to content

Commit ae6cc0d

Browse files
author
Tom McCormick
committed
add test
1 parent e8c3a43 commit ae6cc0d

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

tests/io/test_pyarrow.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2734,7 +2734,6 @@ def test_retry_strategy_not_found() -> None:
27342734
with pytest.warns(UserWarning, match="Could not initialize S3 retry strategy: pyiceberg.DoesNotExist"):
27352735
io.new_input("s3://bucket/path/to/file")
27362736

2737-
27382737
@pytest.mark.parametrize("format_version", [1, 2, 3])
27392738
def test_task_to_record_batches_nanos(format_version: TableVersion, tmpdir: str) -> None:
27402739
arrow_table = pa.table(
@@ -2785,3 +2784,39 @@ def _expected_batch(unit: str) -> pa.RecordBatch:
27852784
)
27862785

27872786
assert _expected_batch("ns" if format_version > 2 else "us").equals(actual_result)
2787+
2788+
def test_parse_location_environment_defaults():
2789+
"""Test that parse_location uses environment variables for defaults."""
2790+
from pyiceberg.io.pyarrow import PyArrowFileIO
2791+
import os
2792+
2793+
# Test with default environment (no env vars set)
2794+
scheme, netloc, path = PyArrowFileIO.parse_location("/foo/bar")
2795+
assert scheme == "file"
2796+
assert netloc == ""
2797+
assert path == "/foo/bar"
2798+
2799+
try:
2800+
# Test with environment variables set
2801+
os.environ["DEFAULT_SCHEME"] = "scheme"
2802+
os.environ["DEFAULT_NETLOC"] = "netloc:8000"
2803+
2804+
scheme, netloc, path = PyArrowFileIO.parse_location("/foo/bar")
2805+
assert scheme == "scheme"
2806+
assert netloc == "netloc:8000"
2807+
assert path == "netloc:8000/foo/bar"
2808+
2809+
# Set environment variables
2810+
os.environ["DEFAULT_SCHEME"] = "hdfs"
2811+
os.environ["DEFAULT_NETLOC"] = "netloc:8000"
2812+
2813+
scheme, netloc, path = PyArrowFileIO.parse_location("/foo/bar")
2814+
assert scheme == "hdfs"
2815+
assert netloc == "netloc:8000"
2816+
assert path == "/foo/bar"
2817+
finally:
2818+
# Clean up environment variables
2819+
if "DEFAULT_SCHEME" in os.environ:
2820+
del os.environ["DEFAULT_SCHEME"]
2821+
if "DEFAULT_NETLOC" in os.environ:
2822+
del os.environ["DEFAULT_NETLOC"]

0 commit comments

Comments
 (0)