[SPARK-55339][Geo][SQL] Implement WKT writer support for Geo objects#54114
[SPARK-55339][Geo][SQL] Implement WKT writer support for Geo objects#54114uros-db wants to merge 3 commits intoapache:masterfrom
Conversation
JIRA Issue Information=== Sub-task SPARK-55339 === This comment was automatically generated by GitHub Actions |
| */ | ||
| protected void appendDimensionSuffix(StringBuilder sb) { | ||
| if (hasZ && hasM) { | ||
| sb.append(" ZM"); |
There was a problem hiding this comment.
nit: can we append " " earlier, to avoid repeating the empty string in all the string literals?
There was a problem hiding this comment.
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.
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/geo/GeometryModel.java
Show resolved
Hide resolved
| * 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)) { |
There was a problem hiding this comment.
how about value is NaN?
Or if value = -0.0?
I wonder these cases are valid?
There was a problem hiding this comment.
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.
What changes were proposed in this pull request?
Enable
toWKTfor 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.