@@ -2638,3 +2638,39 @@ def test_retry_strategy_not_found() -> None:
26382638 io = PyArrowFileIO (properties = {S3_RETRY_STRATEGY_IMPL : "pyiceberg.DoesNotExist" })
26392639 with pytest .warns (UserWarning , match = "Could not initialize S3 retry strategy: pyiceberg.DoesNotExist" ):
26402640 io .new_input ("s3://bucket/path/to/file" )
2641+
2642+ def test_parse_location_environment_defaults ():
2643+ """Test that parse_location uses environment variables for defaults."""
2644+ from pyiceberg .io .pyarrow import PyArrowFileIO
2645+ import os
2646+
2647+ # Test with default environment (no env vars set)
2648+ scheme , netloc , path = PyArrowFileIO .parse_location ("/foo/bar" )
2649+ assert scheme == "file"
2650+ assert netloc == ""
2651+ assert path == "/foo/bar"
2652+
2653+ try :
2654+ # Test with environment variables set
2655+ os .environ ["DEFAULT_SCHEME" ] = "scheme"
2656+ os .environ ["DEFAULT_NETLOC" ] = "netloc:8000"
2657+
2658+ scheme , netloc , path = PyArrowFileIO .parse_location ("/foo/bar" )
2659+ assert scheme == "scheme"
2660+ assert netloc == "netloc:8000"
2661+ assert path == "netloc:8000/foo/bar"
2662+
2663+ # Set environment variables
2664+ os .environ ["DEFAULT_SCHEME" ] = "hdfs"
2665+ os .environ ["DEFAULT_NETLOC" ] = "netloc:8000"
2666+
2667+ scheme , netloc , path = PyArrowFileIO .parse_location ("/foo/bar" )
2668+ assert scheme == "hdfs"
2669+ assert netloc == "netloc:8000"
2670+ assert path == "/foo/bar"
2671+ finally :
2672+ # Clean up environment variables
2673+ if "DEFAULT_SCHEME" in os .environ :
2674+ del os .environ ["DEFAULT_SCHEME" ]
2675+ if "DEFAULT_NETLOC" in os .environ :
2676+ del os .environ ["DEFAULT_NETLOC" ]
0 commit comments