Thanks to visit codestin.com
Credit goes to gitHub.com

Skip to content

[SPARK-55339][Geo][SQL] Implement WKT writer support for Geo objects#54114

Draft
uros-db wants to merge 3 commits intoapache:masterfrom
uros-db:geo-wkt-write
Draft

[SPARK-55339][Geo][SQL] Implement WKT writer support for Geo objects#54114
uros-db wants to merge 3 commits intoapache:masterfrom
uros-db:geo-wkt-write

Conversation

@uros-db
Copy link
Contributor

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

What changes were proposed in this pull request?

Enable toWKT for Well-known text (WKT) representation of geospatial objects.

Same as WKB (Well Known Binary) support, our custom implementation avoids third-party dependencies such as JTS.

Why are the changes needed?

Text-based geospatial objects are necessary for result set support & thrift server enablement.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added new unit tests.

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

Yes, Claude 4.5 Opus.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

JIRA Issue Information

=== Sub-task SPARK-55339 ===
Summary: Implement WKT writer for Geo objects
Assignee: None
Status: Open
Affected: ["4.2.0"]


This comment was automatically generated by GitHub Actions

@github-actions github-actions bot added the SQL label Feb 3, 2026
@uros-db uros-db marked this pull request as draft February 4, 2026 00:23
*/
protected void appendDimensionSuffix(StringBuilder sb) {
if (hasZ && hasM) {
sb.append(" ZM");
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we append " " earlier, to avoid repeating the empty string in all the string literals?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, thanks for pointing it out - although I think that the current version is slightly better because it makes just 1 append call to the string builder per execution path, whereas the alternative would make 2 calls. As for repeated spaces across literals, well we do need to have these strings anyways but that shouldn't be too big of an issue given that there is a fixed limited amount of them. However, I am open to discussion - so please let me know what you think.

* Appends a single coordinate value, formatting integers without decimal point.
*/
private static void appendCoordinate(StringBuilder sb, double value) {
if (value == Math.floor(value) && !Double.isInfinite(value)) {
Copy link
Member

Choose a reason for hiding this comment

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

how about value is NaN?

Or if value = -0.0?

I wonder these cases are valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch - I don't know whether this can really happen, given the current implementation of the WKB parser and the geometry model class hierarchy. I will check and come back to this definitely.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants