4040try :
4141 from gcsfs import GCSFileSystem
4242except ImportError :
43- pass
43+
44+ class GCSFileSystem :
45+ """Placeholder."""
46+
4447
4548PANDAS_FALLBACK_INFO = " Set pandas_fallback=True to ignore this error."
4649NULL_VALUE = "__HIVE_DEFAULT_PARTITION__"
@@ -96,6 +99,7 @@ def read_geopandas(
9699 file_system = file_system ,
97100 use_threads = use_threads ,
98101 pandas_fallback = pandas_fallback ,
102+ filters = filters ,
99103 ** kwargs ,
100104 )
101105
@@ -108,7 +112,9 @@ def read_geopandas(
108112 # because glob is slow without GCSFileSystem from the root partition
109113 if single_eq_filter :
110114 try :
111- expression = "" .join (next (iter (filters ))).replace ("==" , "=" )
115+ expression : list [str ] = "" .join (
116+ [str (x ) for x in next (iter (filters ))]
117+ ).replace ("==" , "=" )
112118 glob_func = _get_glob_func (file_system )
113119 suffix : str = Path (gcs_path ).suffix
114120 paths = glob_func (str (Path (gcs_path ) / expression / f"*{ suffix } " ))
@@ -119,6 +125,7 @@ def read_geopandas(
119125 file_system = file_system ,
120126 use_threads = use_threads ,
121127 pandas_fallback = pandas_fallback ,
128+ filters = filters ,
122129 ** kwargs ,
123130 )
124131 except FileNotFoundError :
@@ -182,7 +189,11 @@ def _read_geopandas_from_iterable(
182189 paths = list (bounds_series .index )
183190
184191 results : list [pyarrow .Table ] = _read_pyarrow_with_treads (
185- paths , file_system = file_system , mask = mask , use_threads = use_threads , ** kwargs
192+ paths ,
193+ file_system = file_system ,
194+ mask = mask ,
195+ use_threads = use_threads ,
196+ ** kwargs ,
186197 )
187198 if results :
188199 try :
@@ -198,10 +209,15 @@ def _read_geopandas_from_iterable(
198209
199210
200211def _read_pyarrow_with_treads (
201- paths : list [str | Path | os .PathLike ], file_system , use_threads , mask , ** kwargs
212+ paths : list [str | Path | os .PathLike ],
213+ file_system ,
214+ use_threads ,
215+ mask ,
216+ filters ,
217+ ** kwargs ,
202218) -> list [pyarrow .Table ]:
203219 read_partial = functools .partial (
204- _read_pyarrow , mask = mask , file_system = file_system , ** kwargs
220+ _read_pyarrow , filters = filters , mask = mask , file_system = file_system , ** kwargs
205221 )
206222 if not use_threads :
207223 return [x for x in map (read_partial , paths ) if x is not None ]
@@ -645,7 +661,7 @@ def expression_match_path(expression: ds.Expression, path: str) -> bool:
645661 """Check if a file path match a pyarrow Expression.
646662
647663 Examples:
648- --------
664+ ---------
649665 >>> import pyarrow.compute as pc
650666 >>> path = 'data/file.parquet/x=1/y=10/name0.parquet'
651667 >>> expression = (pc.Field("x") == 1) & (pc.Field("y") == 10)
@@ -758,6 +774,7 @@ def _read_partitioned_parquet(
758774 ),
759775 file_system = file_system ,
760776 mask = mask ,
777+ filters = filters ,
761778 use_threads = use_threads ,
762779 ** kwargs ,
763780 )
0 commit comments