Skip to content

GeoArrow schema inference reorders multiple geometry columns #3535

Closed

Description

@jiayuasu

Expected behavior

GeoArrow schema inference and the resulting Spark DataFrame should preserve input column order and field types. Each geometry column must retain its original values and row associations.

Actual behavior

With multiple geometry columns, infer_schema inserts fields at the wrong positions because its position counter advances only for non-geometry fields:

  • [first, second, id] becomes [second, first, id].
  • [first, id, second] becomes [first, second, id].

This concerns GeoPandas-to-Spark input schema positions, not Arrow output index metadata or generated field names containing dots.

Steps to reproduce

No Spark session is needed:

import geopandas as gpd
from shapely.geometry import Point
from sedona.spark.geoarrow.geoarrow import infer_schema

gdf = gpd.GeoDataFrame(
    {
        "first": gpd.GeoSeries([Point(1, 2)]),
        "second": gpd.GeoSeries([Point(3, 4)]),
        "id": [1],
    },
    geometry="first",
)

for columns in [["first", "second", "id"], ["first", "id", "second"]]:
    print(columns, "->", infer_schema(gdf[columns]).names)

Both cases fail on the unchanged base and are covered by these regression tests. The related Spark 3.5 integration test uses distinct values in each geometry column and checks their association with each row name.

Sedona version

2.0.0-SNAPSHOT, Apache commit 20efe7d4c4ff13dac154181ace13818f29087991.

Apache Spark version

PySpark 4.1.1 and 4.2.0 dependencies for the pure schema reproduction; Spark 3.5.8 for the later integration validation

API type

Python

Python version

3.12.11 for the pure schema checks; 3.11.13 with Shapely 1.8.5.post1 for the Spark 3.5.8 integration validation

Environment

Local macOS Python environments. The schema reproduction starts no JVM or Spark session.

Existing issues

  • I searched the existing issues and did not find a duplicate.

Proposed fix: #3530

Activity

  1. added a commit that references this issue on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions