lukeplatts opened a new issue, #1115:
URL: https://github.com/apache/sedona-db/issues/1115

   ## Describe the bug
   
   Any query that combines **2 or more non-geometry columns** with an **`ST_*` 
accessor function** (e.g. `ST_IsEmpty`, `ST_IsValid`, `ST_XMin`, `ST_NPoints`) 
applied to a geometry column **sourced from a file scan** (e.g. `read_parquet`) 
panics on every Arrow-materializing export path — `to_arrow_reader()`, 
`to_arrow_table()`, `to_pandas()`, `to_parquet()`. `count()` and `show()` are 
unaffected, since they don't go through Arrow export.
   
   ```
   thread '<unnamed>' panicked at .../arrow-schema-57.3.0/src/schema.rs:375:10:
   index out of bounds: the len is 2 but the index is 2
   ```
   
   The index value scales with the number of extra columns (reproduced with 1, 
2, and 3 — 1 never panics, 2+ always does), which points at a fixed-size 
metadata array (likely CRS/extension-type metadata for the geometry column) 
being indexed by column position without accounting for the other columns in 
the schema.
   
   This affects both the sync (`sedonadb`) and `sedona.db` Python entry points 
and reproduces on a fresh `sedona.db.connect()` with no options set. It is not 
related to column ordering, nullability, or the specific `ST_*` function — 
every accessor function tried reproduces it identically.
   
   ## To Reproduce
   
   ```python
   import pyarrow as pa
   import pyarrow.parquet as pq
   import shapely
   import sedona.db
   
   path = "/tmp/repro.parquet"
   geom = pa.array(
       [shapely.to_wkb(shapely.geometry.Point(1, 2)), 
shapely.to_wkb(shapely.geometry.Point(3, 4))],
       type=pa.binary(),
   )
   pq.write_table(pa.table({"geometry": geom}), path)
   
   sd = sedona.db.connect()
   sd.read_parquet(path).to_view("raw", overwrite=True)
   
   # 2 extra non-geometry columns ('c1', 'c2') + one ST_* accessor on the 
scanned geometry
   sd.sql("""
       CREATE OR REPLACE VIEW g1 AS
       SELECT 'a' AS c1, 'b' AS c2, ST_SetSRID(ST_GeomFromWKB(geometry), 4326) 
AS geometry
       FROM raw
   """)
   sd.sql("CREATE OR REPLACE VIEW t AS SELECT *, ST_IsEmpty(geometry) AS _e 
FROM g1")
   
   for batch in sd.sql("SELECT * FROM t").to_arrow_reader():
       pass  # panics here
   ```
   
   Reducing to a single extra column (`c1` only, dropping `c2`) does **not** 
panic. Reducing to zero `ST_*` calls does not panic. Using a literal geometry 
(`ST_Point(1, 2)`) instead of one read from a file scan does not panic.
   
   ## Expected behavior
   
   The query executes and exports without panicking, as it did in `sedonadb` 
0.3.0 (confirmed no reproduction there).
   
   ## Environment
   
   - sedonadb: 0.4.0 (conda-forge, `py314h9a0e2ed_0` build, linux-64 and 
osx-arm64 both reproduce)
   - Python: 3.14
   - OS: reproduced on both macOS (osx-arm64) and Linux (linux-64) conda-forge 
builds
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to