Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SEDONA-673] Fix issue when loading geoparquet file without bbox metadata. #1681

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ object GeoParquetSpatialFilter {
def evaluate(columns: Map[String, GeometryFieldMetaData]): Boolean = {
columns.get(columnName).forall { column =>
val bbox = column.bbox
if (bbox.isEmpty) {
return true
}

val columnEnvelope =
queryWindow.getFactory.toGeometry(new Envelope(bbox(0), bbox(2), bbox(1), bbox(3)))
predicateType match {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class geoparquetIOTests extends TestBaseScala with BeforeAndAfterAll {
val legacyparquetdatalocation: String =
resourceFolder + "parquet/legacy-parquet-nested-columns.snappy.parquet"
val geoparquetoutputlocation: String = resourceFolder + "geoparquet/geoparquet_output/"
val overtureBBOX: String = resourceFolder + "geoparquet/overture/bbox.geoparquet"

override def afterAll(): Unit = FileUtils.deleteDirectory(new File(geoparquetoutputlocation))

Expand Down Expand Up @@ -732,6 +733,18 @@ class geoparquetIOTests extends TestBaseScala with BeforeAndAfterAll {
}
}

describe("loading one file geoparquet and filtering") {
it("should not fail when bbox is not available in geoparquet metadata") {
val numberOfRecords = sparkSession.read
.format("geoparquet")
.load(overtureBBOX)
.where("ST_Intersects(geometry, ST_PolygonFromEnvelope(0, 0, 1, 1))")
.count()

assert(numberOfRecords == 9)
}
}

def validateGeoParquetMetadata(path: String)(body: org.json4s.JValue => Unit): Unit = {
val parquetFiles = new File(path).listFiles().filter(_.getName.endsWith(".parquet"))
parquetFiles.foreach { filePath =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class geoparquetIOTests extends TestBaseScala with BeforeAndAfterAll {
val legacyparquetdatalocation: String =
resourceFolder + "parquet/legacy-parquet-nested-columns.snappy.parquet"
val geoparquetoutputlocation: String = resourceFolder + "geoparquet/geoparquet_output/"
val overtureBBOX: String = resourceFolder + "geoparquet/overture/bbox.geoparquet"

override def afterAll(): Unit = FileUtils.deleteDirectory(new File(geoparquetoutputlocation))

Expand Down Expand Up @@ -758,6 +759,18 @@ class geoparquetIOTests extends TestBaseScala with BeforeAndAfterAll {
}
}

describe("loading one file geoparquet and filtering") {
it("should not fail when bbox is not available in geoparquet metadata") {
val numberOfRecords = sparkSession.read
.format("geoparquet")
.load(overtureBBOX)
.where("ST_Intersects(geometry, ST_PolygonFromEnvelope(0, 0, 1, 1))")
.count()

assert(numberOfRecords == 9)
}
}

def validateGeoParquetMetadata(path: String)(body: org.json4s.JValue => Unit): Unit = {
val parquetFiles = new File(path).listFiles().filter(_.getName.endsWith(".parquet"))
parquetFiles.foreach { filePath =>
Expand Down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can you replicate the test to all Spark versions?
  2. Can you add comments in the test case and explain this is using a geoparquet has no bbox in metadata?

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class geoparquetIOTests extends TestBaseScala with BeforeAndAfterAll {
val legacyparquetdatalocation: String =
resourceFolder + "parquet/legacy-parquet-nested-columns.snappy.parquet"
val geoparquetoutputlocation: String = resourceFolder + "geoparquet/geoparquet_output/"

val overtureBBOX: String = resourceFolder + "geoparquet/overture/bbox.geoparquet"
override def afterAll(): Unit = FileUtils.deleteDirectory(new File(geoparquetoutputlocation))

describe("GeoParquet IO tests") {
Expand Down Expand Up @@ -761,6 +761,18 @@ class geoparquetIOTests extends TestBaseScala with BeforeAndAfterAll {
}
}

describe("loading one file geoparquet and filtering") {
it("should not fail when bbox is not available in geoparquet metadata") {
val numberOfRecords = sparkSession.read
.format("geoparquet")
.load(overtureBBOX)
.where("ST_Intersects(geometry, ST_PolygonFromEnvelope(0, 0, 1, 1))")
.count()

assert(numberOfRecords == 9)
}
}

def validateGeoParquetMetadata(path: String)(body: org.json4s.JValue => Unit): Unit = {
val parquetFiles = new File(path).listFiles().filter(_.getName.endsWith(".parquet"))
parquetFiles.foreach { filePath =>
Expand Down
Loading