Skip to content

Comments

[SPARK-55530][Geo][SQL] Support Geo result sets in Hive and Thrift server#54325

Open
uros-db wants to merge 7 commits intoapache:masterfrom
uros-db:geo-thrift-server
Open

[SPARK-55530][Geo][SQL] Support Geo result sets in Hive and Thrift server#54325
uros-db wants to merge 7 commits intoapache:masterfrom
uros-db:geo-thrift-server

Conversation

@uros-db
Copy link
Contributor

@uros-db uros-db commented Feb 14, 2026

What changes were proposed in this pull request?

Implement geospatial data output display in Extended Well-Known Text (EWKT) format and add the appropriate geospatial type mapping in Hive Thrift Server.

Why are the changes needed?

Display Geometry and Geography values in a human-readable format, which allows projecting geospatial data in Spark SQL and Thrift Server.

Does this PR introduce any user-facing change?

Yes, geospatial data is now displayed using EWKT.

How was this patch tested?

  • Unit tests for WKT/EWKT writing from geo catalyst classes and STUtils class.
  • HiveResult unit tests for standalone and nested geometry/geography formatting.
  • SparkExecuteStatementOperation unit tests for thrift server type mapping.
  • RandomDataGenerator unit test for generating random geospatial data.
  • End-to-end SQL golden file tests for geospatial result set display.

Was this patch authored or co-authored using generative AI tooling?

No.

Copy link
Contributor Author

@uros-db uros-db left a comment

Choose a reason for hiding this comment

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

@cloud-fan Please review.

case (g: Geometry, dt: GeometryType) =>
val internalGeom = STUtils.serializeGeomFromWKB(g, dt)
val s = STUtils.stAsEwkt(internalGeom).toString
if (nested) "\"" + s + "\"" else s
Copy link
Contributor

Choose a reason for hiding this comment

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

not related to this PR, but seems we forget to do the same for VariantType

@uros-db uros-db requested a review from cloud-fan February 16, 2026 19:49
…/thriftserver/RowSetUtils.scala

Co-authored-by: Wenchen Fan <cloud0fan@gmail.com>
@uros-db uros-db requested a review from cloud-fan February 19, 2026 14:11
@uros-db
Copy link
Contributor Author

uros-db commented Feb 20, 2026

CI failure looks unrelated. Otherwise, this should be ready @cloud-fan.

Copy link
Member

@szehon-ho szehon-ho left a comment

Choose a reason for hiding this comment

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

mostly lgtm, small suggestions

WkbReader reader = new WkbReader(true);
GeometryModel model = reader.read(Arrays.copyOfRange(
getBytes(), WKB_OFFSET, getBytes().length));
return model.toString();
Copy link
Member

Choose a reason for hiding this comment

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

i think it would have been cleaner to have explicit toWKT in GeometryModel, as toString may change. It can be separate from this pr though

public byte[] toEwkt() {
// Once EWKT conversion is implemented, it should support various precisions.
throw new UnsupportedOperationException("Geography EWKT conversion is not yet supported.");
String ewkt = "SRID=" + srid() + ";" + toWktInternal();
Copy link
Member

Choose a reason for hiding this comment

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

ok, so all wkt is valid ewkt, and we add extra SRID=... make sense to me.

public byte[] toWkt() {
// Once WKT conversion is implemented, it should support various precisions.
throw new UnsupportedOperationException("Geometry WKT conversion is not yet supported.");
return toWktInternal().getBytes(StandardCharsets.UTF_8);
Copy link
Member

Choose a reason for hiding this comment

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

we could make this in Geo base class, but its quite small

}
}
case gt: GeometryType =>
val possibleGeometriesWKB = Seq(
Copy link
Member

Choose a reason for hiding this comment

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

can you comment what these values are?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants