Skip to content

Commit

Permalink
Arrow/Parquet: support LargeString and LargeBinary for geometry colum…
Browse files Browse the repository at this point in the history
…ns (read support only)
  • Loading branch information
rouault committed Oct 26, 2023
1 parent e9fb165 commit 87b8653
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 39 deletions.
30 changes: 27 additions & 3 deletions autotest/ogr/ogr_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import gdaltest
import ogrtest
import pytest
import test_cli_utilities

from osgeo import gdal, ogr, osr

Expand Down Expand Up @@ -493,7 +494,6 @@ def test_ogr_parquet_1(use_vsi):


def test_ogr_parquet_test_ogrsf_test():
import test_cli_utilities

if test_cli_utilities.get_test_ogrsf_path() is None:
pytest.skip()
Expand All @@ -511,7 +511,6 @@ def test_ogr_parquet_test_ogrsf_test():


def test_ogr_parquet_test_ogrsf_example():
import test_cli_utilities

if test_cli_utilities.get_test_ogrsf_path() is None:
pytest.skip()
Expand All @@ -529,7 +528,6 @@ def test_ogr_parquet_test_ogrsf_example():


def test_ogr_parquet_test_ogrsf_all_geoms():
import test_cli_utilities

if test_cli_utilities.get_test_ogrsf_path() is None:
pytest.skip()
Expand Down Expand Up @@ -3085,3 +3083,29 @@ def test_ogr_parquet_write_arrow_rewind_polygon(tmp_vsimem):
lyr = ds.GetLayer(0)
f = lyr.GetNextFeature()
assert f.GetGeometryRef().ExportToWkt() == "POLYGON ((0 0,1 1,0 1,0 0))"


###############################################################################


@gdaltest.enable_exceptions()
@pytest.mark.parametrize(
"filename",
[
"data/parquet/poly_wkb_large_binary.parquet",
"data/parquet/poly_wkt_large_string.parquet",
],
)
def test_ogr_parquet_read_large_binary_or_string_for_geometry(filename):
ds = ogr.Open(filename)
lyr = ds.GetLayer(0)
f = lyr.GetNextFeature()
assert f.GetGeometryRef() is not None

if test_cli_utilities.get_test_ogrsf_path() is None:
ret = gdaltest.runexternal(
test_cli_utilities.get_test_ogrsf_path() + " -ro " + filename
)

assert "INFO" in ret
assert "ERROR" not in ret
4 changes: 3 additions & 1 deletion ogr/ogrsf_frmts/arrow_common/ogr_arrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ class OGRArrowLayer CPL_NON_FINAL
void ExploreExprNode(const swq_expr_node *poNode);
bool UseRecordBatchBaseImplementation() const;

template <typename SourceOffset>
static struct ArrowArray *
CreateWKTArrayFromWKBArray(const struct ArrowArray *sourceArray);
CreateWKBArrayFromWKTArray(const struct ArrowArray *sourceArray);

int GetArrowSchemaInternal(struct ArrowSchema *out) const;

Expand All @@ -116,6 +117,7 @@ class OGRArrowLayer CPL_NON_FINAL
int m_iBBOXMaxYField = -1;

const arrow::BinaryArray *m_poArrayWKB = nullptr;
const arrow::LargeBinaryArray *m_poArrayWKBLarge = nullptr;
const arrow::Array *m_poArrayBBOX = nullptr;
const arrow::DoubleArray *m_poArrayMinX = nullptr;
const arrow::DoubleArray *m_poArrayMinY = nullptr;
Expand Down
Loading

0 comments on commit 87b8653

Please sign in to comment.