Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

### Bug fixes

- Fix regression in reading date columns (#616)
- Fix regression in reading date columns (#616).
- Fix regression in `read_dataframe` when `use_arrow=True` and `columns` is used to filter
out columns of some specific types (#611)
out columns of some specific types (#611).
- Fix overwriting a corrupt fileGDB directory (#600).

## 0.12.0 (2025-11-26)

Expand Down
11 changes: 10 additions & 1 deletion pyogrio/_io.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import locale
import logging
import math
import os
import shutil
import sys
import warnings
from pathlib import Path
Expand Down Expand Up @@ -2408,7 +2409,15 @@ cdef create_ogr_dataset_layer(
raise exc

# otherwise create from scratch
os.unlink(path)
if (
driver == "OpenFileGDB"
and os.path.isdir(path)
and os.path.splitext(path)[1] == ".gdb"
):
# An FileGDB "file" is a directory instead of a file, so use rmtree
shutil.rmtree(path)
else:
os.unlink(path)

ogr_dataset = NULL

Expand Down
27 changes: 27 additions & 0 deletions pyogrio/tests/test_geopandas_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3334,6 +3334,33 @@ def test_write_geojson_rfc7946_coordinates(tmp_path, use_arrow):
assert np.array_equal(gdf_in_appended.geometry.values, points + points_append)


@pytest.mark.requires_arrow_write_api
def test_write_openfilegdb_overwrite_corrupt(tmp_path, use_arrow):
"""Test to overwriting an existing corrupt OpenFileGDB.

Test added in context of https://github.com/geopandas/pyogrio/issues/598
"""
# Create a corrupt OpenFileGDB file. An empty directory suffices.
test_path = tmp_path / "test.gdb"
test_path.mkdir()

# Overwrite the corrupt OpenFileGDB
gdf = gp.GeoDataFrame(
{"id": [1.0, 2.0, 3.0]},
geometry=[shapely.Point(x, x) for x in range(3)],
crs="EPSG:4326",
)
write_dataframe(
gdf, test_path, layer="test_layer", driver="OpenFileGDB", use_arrow=use_arrow
)

# Read back and verify it was (over)written correctly
assert test_path.exists()
assert test_path.is_dir()
read_gdf = read_dataframe(test_path, use_arrow=use_arrow)
assert_geodataframe_equal(gdf, read_gdf)


@pytest.mark.requires_arrow_write_api
@pytest.mark.skipif(
not GDAL_HAS_PARQUET_DRIVER, reason="Parquet driver is not available"
Expand Down