Geospatial datatype support#988
Conversation
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
885046b to
ab7556e
Compare
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
jayantsing-db
left a comment
There was a problem hiding this comment.
Added some comments. Can we have a fake service test for this?
| if (object instanceof DatabricksGeography) { | ||
| return (DatabricksGeography) object; | ||
| } |
There was a problem hiding this comment.
This is not a good conversion right (because we seem to have a specific converter)? In that case, please delete this and let the default impl throw exception.
Exceptions from this method in a happy path will then indicate that the correct converter bean is not injected instead of us doing a faulty conversion.
There was a problem hiding this comment.
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
…on the current version) Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
| */ | ||
| @Override | ||
| public byte[] getWKB() throws DatabricksValidationException { | ||
| return WKTConverter.toWKB(wkt); |
There was a problem hiding this comment.
we should consider storing this value as computation can be very expensive
There was a problem hiding this comment.
Storing wkb it in a class variable for reuse. Implemented in #1062
| private boolean isGeometryColumn(List<String> arrowMetadata, int index) { | ||
| return arrowMetadata != null | ||
| && arrowMetadata.size() > index | ||
| && arrowMetadata.get(index) != null |
There was a problem hiding this comment.
where is this coming from?
what kind of metadata is this ?
There was a problem hiding this comment.
removed the metadata usage completely (#1062)
| int dataSrid = WKTConverter.extractSRIDFromEWKT(ewkt); | ||
| String cleanWkt = WKTConverter.removeSRIDFromEWKT(ewkt); | ||
|
|
||
| // Extract SRID from metadata if not present in data |
There was a problem hiding this comment.
ok this is a bit confusing.
the only time srid won't be present in EWKT is when SRID=0.
All other times SRID will be present.
Also SRID in metadata will be set to -1 when SRIDs per row differ, and per row will have SRID unless its 0 for that row
There was a problem hiding this comment.
Updated the implementation for srid extraction: #1062
## Description <!-- Provide a brief summary of the changes made and the issue they aim to address.--> Added support for geospatial datatype ## Testing <!-- Describe how the changes have been tested--> Tested in all paths - combinations of thrift/sea, arrow/non-arrow, complex/non-complex datatype - ensuring similar behaviour with other datatypes. ## Additional Notes to the Reviewer <!-- Share any additional context or insights that may help the reviewer understand the changes better. This could include challenges faced, limitations, or compromises made during the development process. Also, mention any areas of the code that you would like the reviewer to focus on specifically. --> --------- Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com> Signed-off-by: sshpuntoff <samshpuntoff@gmail.com>
| return convertToGeospatial(object, GEOGRAPHY, DatabricksGeography::new); | ||
| } | ||
|
|
||
| private <T extends IDatabricksGeospatial> T convertToGeospatial( |
There was a problem hiding this comment.
this converted does not behave the same as ArrowToJavaObjectConverter.
tbh this one is more precise
There was a problem hiding this comment.
updated ArrowToJavaObjectConverter implementation in #1062
| try { | ||
| // Look for pattern like "GEOMETRY(32633)" or "GEOGRAPHY(4326)" | ||
| Pattern pattern = | ||
| typePrefix.equals(GEOMETRY) ? GEOMETRY_SRID_PATTERN : GEOGRAPHY_SRID_PATTERN; |
There was a problem hiding this comment.
also geography pattern is incorrect i think, this will fail.
we also send GEOGRAPHY(, )
## Description <!-- Provide a brief summary of the changes made and the issue they aim to address.--> This PR addresses comments from Milan's review on PR #988 (Geospatial support implementation). ## Changes ### 1. Cache WKB Value for Performance - Added `wkb` field to `AbstractDatabricksGeospatial` to cache WKB representation - WKB now computed once in constructor instead of on every `getWKB()` call ### 2. Simplify SRID Extraction Logic - Removed metadata-based SRID extraction entirely - Per Milan's clarification: "SRID is always present in EWKT unless it's 0" - Simplified `convertToGeospatial()` to only extract SRID from EWKT data - Removed `extractSRIDFromMetadata()` method and regex patterns - Removed unused `arrowMetadata` parameter from `convertToGeospatial()` ## Testing - All unit tests are passing ## Additional Notes to the Reviewer <!-- Share any additional context or insights that may help the reviewer understand the changes better. This could include challenges faced, limitations, or compromises made during the development process. Also, mention any areas of the code that you would like the reviewer to focus on specifically. --> NO_CHANGELOG=true (changelog already added in previous PR) Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Description
Added support for geospatial datatype
Testing
Tested in all paths - combinations of thrift/sea, arrow/non-arrow, complex/non-complex datatype - ensuring similar behaviour with other datatypes.
Additional Notes to the Reviewer