Skip to content

Commit 16ccc66

Browse files
committed
docs: clarify geoarrow optional; tidy geospatial parsing notes
1 parent f4359b4 commit 16ccc66

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

mkdocs/docs/geospatial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Both types store values as WKB (Well-Known Binary) bytes.
1414
## Requirements
1515

1616
- Iceberg format version 3 or higher
17-
- `geoarrow-pyarrow` for full GeoArrow extension type support (optional: `pip install pyiceberg[geoarrow]`)
17+
- Optional: `geoarrow-pyarrow` for GeoArrow extension type metadata and interoperability. Without it, geometry and geography are written as binary in Parquet while the Iceberg schema still preserves the spatial type. Install with `pip install pyiceberg[geoarrow]`.
1818

1919
## Usage
2020

pyiceberg/types.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
DEFAULT_GEOGRAPHY_ALGORITHM = "spherical"
6868

6969
# Regex patterns for parsing geometry and geography type strings
70-
# Matches: geometry, geometry('CRS'), geometry("CRS")
70+
# Matches: geometry, geometry('CRS'), geometry('crs'), geometry("CRS")
7171
GEOMETRY_REGEX = re.compile(r"geometry(?:\(\s*['\"]([^'\"]+)['\"]\s*\))?$")
72-
# Matches: geography, geography('CRS'), geography('CRS', 'algo')
72+
# Matches: geography, geography('CRS'), geography('crs', 'algo')
7373
GEOGRAPHY_REGEX = re.compile(r"geography(?:\(\s*['\"]([^'\"]+)['\"](?:\s*,\s*['\"]([^'\"]+)['\"])?\s*\))?$")
7474

7575

@@ -182,8 +182,10 @@ def handle_primitive_type(cls, v: Any, handler: ValidatorFunctionWrapHandler) ->
182182
# Pydantic works mostly around dicts, and there seems to be something
183183
# by not serializing into a RootModel, might revisit this.
184184
if isinstance(v, str):
185-
# When constructing GeometryType/GeographyType directly with CRS/algorithm values,
186-
# skip the type string parsing to avoid infinite recursion
185+
# GeometryType/GeographyType inherit this validator, but their root values are
186+
# a CRS string (or CRS, algorithm tuple). If we try to parse those as type
187+
# strings here, we'd re-enter this validator (or raise) instead of letting
188+
# pydantic validate the raw root values.
187189
if cls.__name__ == "GeometryType" and not v.startswith("geometry"):
188190
return handler(v)
189191
if cls.__name__ == "GeographyType" and not v.startswith("geography"):

0 commit comments

Comments
 (0)