[DO NOT SQUASH MERGE] Geospatial functions (STGeometryType, Parse, STNumPoints, MakeValid)#4667
Open
Gopalverma062 wants to merge 4 commits intobabelfish-for-postgresql:BABEL_6_X_DEVfrom
Conversation
…for-postgresql#4509) Implemented the STGeometryType() method for both sys.GEOMETRY and sys.GEOGRAPHY types, extending the existing geospatial functionality in Babelfish. This function returns the geometry type name (Point, LineString, Polygon, etc.) with full TSQL compatibility. Changes Made Function Implementations: STGeometryType for sys.GEOMETRY - Returns geometry type name with proper validation STGeometryType for sys.GEOGRAPHY - Returns geography type name with same behavior Utilizes PostGIS functions with necessary adjustments for TSQL compatibility Strips 'ST_' prefix from PostGIS type names to match TSQL Server format Task: BABEL-6310 Signed-off by: gopalgv [email protected]
…-postgresql#4518) Implemented Parse function support for GeoSpatial TSQL data types that was previously unsupported in Babelfish. The Parse function has been added for both geometry and geography data types. Changes include: Implemented geometry::Parse() and geography::Parse() functions by utilizing PostGIS parsing capabilities with necessary adjustments to ensure TSQL compatibility. Added Parse function definitions to the TSQL parser to recognize these new static methods. Ensured proper syntax handling for Parse function, including NVARCHAR parameter types and return values. Examples: DECLARE @geomText NVARCHAR(MAX); SET @geomText = 'POINT(1.0 2.0)'; SELECT geometry::Parse(@geomText).STAsText() AS ParsedGeometry; GO ParsedGeometry -------------- POINT(1 2) DECLARE @geogText NVARCHAR(MAX); SET @geogText = 'LINESTRING(0 0, 1 1, 2 2)'; SELECT geography::Parse(@geogText).STAsText() AS ParsedGeography; GO ParsedGeography --------------- LINESTRING(0 0,1 1,2 2) Task: BABEL-6310 Signed-off by: Gopalgv [email protected]
…elfish-for-postgresql#4510) Implemented the STNumPoints GeoSpatial TSQL function that was previously unsupported in Babelfish. BABEL-6329 --------- Co-authored-by: Gopal Verma <[email protected]>
…stgresql#4513) Implemented the MakeValid GeoSpatial TSQL function that was previously unsupported in Babelfish. Added sys.MakeValid(geom sys.GEOMETRY) function in geometry.sql Added sys.MakeValid(geog sys.GEOGRAPHY) function in geography.sql Delegates to respective helper functions for processing invalid geometries. Functions are marked as IMMUTABLE STRICT PARALLEL SAFE for optimal performance. Task: BABEL-6310 Signed-off-by: Gopal Verma <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR cherry-picks four geospatial feature commits from the BABEL_5_X development branch into
BABEL_6_X.Currently, Babelfish on the 6.x branch does not support several T-SQL geospatial methods (
STGeometryType(),Parse(),STNumPoints(),MakeValid()) forsys.GEOMETRYandsys.GEOGRAPHYtypes.With this change, the following geospatial functions are now available on the
BABEL_6_Xbranch:Point,LineString,Polygon, etc.) for geometry and geography instances. Strips theST_prefix from PostGIS output to match T-SQL format.GEOMETRY::Parse()andGEOGRAPHY::Parse()behavior.ST_MakeValidwith T-SQL-compatible behavior.Why: These are essential T-SQL geospatial methods required for SQL compatibility. Cherry-picking into
BABEL_6_Xensures the 6.x release branch includes this geospatial functionality.Cherry-picked commits:
Implement STGeometryType for geometry and geography types (#4509)Implementation of parse geography and geometry datatype (#4518)Supported PostGIS Function: STNumPoints for Geospatial datatypes (#4510)MakeValid implementation for geometry and geography (#4513)Issues Resolved
for geometry and geography types
Test Scenarios Covered
Use case based —
STGeometryType()on all OGC types (Point,LineString,Polygon,MultiPoint,MultiLineString,MultiPolygon,GeometryCollection)Parse()with valid WKT strings for both geometry and geographySTNumPoints()on single and multi-part geometries/geographiesMakeValid()on invalid geometries (e.g., self-intersecting polygons, bowtie polygons)Boundary conditions —
NULLinputs returnNULLfor all functionsSTNumPoints()Arbitrary inputs —
Negative test cases —
Parse()Minor version upgrade tests —
BABEL_6_XbranchMajor version upgrade tests —
Performance tests —
Tooling impact —
Client tests —
Check List
Signed-off-by: gopalgv <[email protected]>By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.