BABEL_6348_MULTIPOINT_SUPPORT#4662
Open
Gopalverma062 wants to merge 4 commits intobabelfish-for-postgresql:BABEL_5_X_DEVfrom
Open
BABEL_6348_MULTIPOINT_SUPPORT#4662Gopalverma062 wants to merge 4 commits intobabelfish-for-postgresql:BABEL_5_X_DEVfrom
Gopalverma062 wants to merge 4 commits intobabelfish-for-postgresql:BABEL_5_X_DEVfrom
Conversation
d85e56b to
5dfc3ce
Compare
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
Currently, Babelfish supports
geometryandgeographyspatial types forPoint,LineString, andPolygongeometries. Attempting to useMultiPointgeometry type results in an "unsupported geometry type" error across all input/output paths including WKT text input, binary (varbinary) conversion, and spatial functions likeSTGeomFromTextandSTMPointFromText.With this change, Babelfish now fully supports the MultiPoint geometry type for both
geometryandgeographydata types. Users can create, store, retrieve, convert, and validate MultiPoint geometries through all existing spatial interfaces, matching T-SQL/MSSQL Server behavior.Why: MultiPoint is a fundamental OGC geometry type used in real-world spatial applications to represent collections of discrete point locations (e.g., sensor networks, store locations, sample sites). Supporting it closes a significant gap in spatial type coverage and moves Babelfish closer to full T-SQL spatial compatibility.
How the code was changed:
WKT Parser (grammar + rewrite functions): Added grammar rules for parsing
MULTIPOINT((x y), ...)andMULTIPOINT Z/M/ZM(...)syntax in both parenthesized and bare coordinate formats. Addedrewrite_multipoint_wkt()andrewrite_dim_multipoint_wkt()functions for WKT normalization.T-SQL CLR Binary ↔ PostGIS WKB conversion (
spatialtypes.c):STROKEfigures andPOINTchild shapes, and conversion from CLR columnar coordinate layout to PostGIS WKB MultiPoint format.Geography validation: Added MultiPoint coordinate validation for latitude/longitude range constraints using
ST_GeometryNPostGIS accessor — consistent with the pattern used for other geometry types.SQL functions (
geometry.sql): AddedSTMPointFromTextfunctions for both geometry and geography types with proper NULL handling, SRID validation, and type checking.Empty geometry handling: Added support for empty MultiPoint in both CLR binary detection (props byte
0x04withEMPTY_COORDpattern andnpoints=0with Z/M flags) and PostGIS WKB output.Test coverage: Added 12–13 MultiPoint test cases across geometry and geography ODBC tests covering 2D, Z, M, ZM, mixed dimensions, NULL coordinate stripping, single-point, empty, and different SRID scenarios.
Issues Resolved
sys.geometryandsys.geographydata typesgeometry::STGeomFromText('MULTIPOINT(...)')now worksgeography::STGeomFromText('MULTIPOINT(...)')now works with latitude/longitude validationgeometry::STMPointFromText()andgeography::STMPointFromText()functions addedvarbinary↔geometry/geography) for MultiPointSTAsText()andSTAsBinary()output for MultiPointMULTIPOINT EMPTY) handling in all pathsTest Scenarios Covered
Use case based -
STGeomFromTextwith geometry and geography typesSTMPointFromTextwith type validationgeometry→varbinary→geometryfor all dimension variantsBoundary conditions -
MULTIPOINT((1 2))— minimum valid collectionMULTIPOINT EMPTY— zero pointsMULTIPOINT((1 2 NULL), (3 4 NULL))stripped to 2DMULTIPOINT((1 2 NULL NULL), (3 4 NULL NULL))stripped to 2DArbitrary inputs -
MULTIPOINT((1 2), (3 4))MULTIPOINT((1 2 3), (4 5 6))MULTIPOINT((1 2 NULL 3), (4 5 NULL 6))MULTIPOINT((1 2 3 4), (5 6 7 8))MULTIPOINT((1 2 3), (4 5))— second point gets Z=NaNMULTIPOINT((1 2 NULL 3), (4 5))— second point gets M=NaNMULTIPOINT((1 2 3 4), (5 6))— second point gets Z=NaN, M=NaNMULTIPOINT(1 2, 3 4)— without inner parenthesesMULTIPOINT((1 2), (3 4))with SRID=0 (geometry only)Negative test cases -
STMPointFromTextwith non-MultiPoint input (e.g.,POINT,LINESTRING) — expects errorSTMPointFromTextwith NULL SRID — expects parameter errorSTMPointFromTextwith negative SRID — expects errorvarbinarydata conversion to MultiPoint — expects conversion errorMinor version upgrade tests -
Major version upgrade tests -
Performance tests -
Tooling impact -
psqlodbctest frameworkClient tests -
Check List
[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.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.