Implemetation of parse geography and geometry datatype#4518
Implemetation of parse geography and geometry datatype#4518shardgupta merged 18 commits intobabelfish-for-postgresql:BABEL_5_X_DEVfrom
Conversation
Pull Request Test Coverage Report for Build 22102330700Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
| RETURNS sys.GEOMETRY | ||
| AS $$ | ||
| BEGIN | ||
| IF UPPER(geometry_tagged_text::text COLLATE "default") = 'NULL' THEN |
There was a problem hiding this comment.
Why do we need to cast it to text first? Can't we directly compare the nvarchar?
| RETURNS sys.GEOMETRY | ||
| AS $$ | ||
| BEGIN | ||
| IF UPPER(geometry_tagged_text COLLATE "default") = 'NULL' THEN |
There was a problem hiding this comment.
Parse function should be implemented similar to stgeomfromtext. Please verify.
There was a problem hiding this comment.
yes i follow the same structure in Parse as a STGeomfromtext
| INSERT INTO TestGeospatialParse_GeometryTable3 (ID, GeomColumn) VALUES (1, geometry::Point(3.0, 4.0, 4326)); | ||
| ~~ROW COUNT: 1~~ | ||
|
|
||
| INSERT INTO TestGeospatialParse_GeometryTable3 (ID, GeomColumn) VALUES (2, geometry::STGeomFromText('LINESTRING(0 0, 1 1, 2 2)', 4326)); |
There was a problem hiding this comment.
These tests should be like geometry::Parse('LINESTRING(0 0, 1 1, 2 2)', 4326)); . Need to update all the tests.
There was a problem hiding this comment.
done i have fixed it
| INSERT INTO TestGeospatialParse_GeographyTable3 (ID, GeogColumn) VALUES (1, geography::Point(3.0, 4.0, 4326)); | ||
| ~~ROW COUNT: 1~~ | ||
|
|
||
| INSERT INTO TestGeospatialParse_GeographyTable3 (ID, GeogColumn) VALUES (2, geography::STGeomFromText('LINESTRING(0 0, 1 1, 2 2)', 4326)); |
There was a problem hiding this comment.
We need more coverage like: Linestring with XY, XYM, XYZ, XYZM points
There was a problem hiding this comment.
done i have addded the more table and testcases which covering XY, XYM, XYZ, XYZM
| CREATE VIEW TestGeospatialMethods_empty_ValFromGeomTemp AS SELECT location.STIsEmpty() FROM TestGeospatialMethods_SPATIALPOINTGEOM_dttemp ORDER BY location.STX; | ||
|
|
||
| CREATE VIEW TestGeospatialMethods_empty_TextFromGeomTemp AS SELECT location.STIsEmpty() AS Dimension FROM TestGeospatialMethods_SPATIALPOINTGEOG_dttemp ORDER BY location.Lat; | ||
| CREATE VIEW TestGeospatialMethods_empty_TextFromGeomTemp AS SELECT location.STIsEmpty() AS Dimension FROM TestGeospatialMethods_SPATIALPOINTGEOG_dttemp ORDER BY location.Lat; |
There was a problem hiding this comment.
Please remove changes in Test-spatial-functions-2 files.
|
|
||
| DECLARE @geogText NVARCHAR(MAX); | ||
| SET @geogText = 'POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'; | ||
| SELECT geography::Parse(@geogText).STAsText() AS ParsedGeography; |
There was a problem hiding this comment.
We should also test Parse function alone without STAsText
There was a problem hiding this comment.
i have added the testcase that test parse alone without STAsText
| Function sys.geography(sys.bpchar) | ||
| Function sys.geography(sys.geography,integer,boolean) | ||
| Function sys.geography(text,integer,boolean) | ||
| Function sys.geography__parse(sys.nvarchar) |
There was a problem hiding this comment.
We can remove this by creating a dependency for Parse function eg. CREATE VIEW
| RETURNS sys.GEOGRAPHY | ||
| AS $$ | ||
| BEGIN | ||
| IF UPPER(geography_tagged_text COLLATE "default") = 'NULL' THEN |
There was a problem hiding this comment.
COLLATE "default" should not be used here. use DATABASE_DEFAULT instead. "default" is a postgres collation, not babelfish collation
There was a problem hiding this comment.
yes i have fixed it
| RAISE EXCEPTION 'parse error - invalid geometry'; | ||
| END IF; | ||
|
|
||
| RETURN sys.geogfromtext_helper(geography_tagged_text::text, 4326); |
There was a problem hiding this comment.
Why do we need to cast geography_tagged_text to text again? sys.geogfromtext_helper should be doing that implicitly
There was a problem hiding this comment.
i have fixed it
| RETURN NULL; | ||
| END IF; | ||
| -- Reject Z/ZM dimension qualifier | ||
| IF geography_tagged_text COLLATE "default" ~* '\s+ZM?\s*\(' THEN |
There was a problem hiding this comment.
Same comment as above
| $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; | ||
|
|
||
| --Parse | ||
| CREATE OR REPLACE FUNCTION sys.Geometry__Parse(geometry_tagged_text sys.NVARCHAR) |
There was a problem hiding this comment.
Same comment as above
|
|
||
| hierarchyid_static_method | ||
| : GETROOT | ||
| | PARSE |
There was a problem hiding this comment.
Why did we remove from here?
There was a problem hiding this comment.
PARSE was incorrectly categorized under hierarchyid_static_method. After discussing with Rohit i ,removed it from here
| @@ -0,0 +1,382 @@ | |||
| --Parse | |||
There was a problem hiding this comment.
Please add comments stating what are we testing for ease of reviewing. Thanks!
e04abbc
into
babelfish-for-postgresql:BABEL_5_X_DEV
…-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 gopalgv@amazon.com
…-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 gopalgv@amazon.com
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 gopalgv@amazon.com
Description
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:
Function Implementation:
geometry::Parse()andgeography::Parse()functions by utilizing PostGIS parsing capabilities with necessary adjustments to ensure TSQL compatibility.Parser Updates:
Test Cases:
Error Handling:
Extending existing functionalities:
hierarchyid::Parse()support for completenessTesting:
Examples:
For
geometry::ParseOutput:
For
geography::ParseOutput:
For Empty Geometry Parsing
Output:
Issues Resolved
Task: 6339
Signed-off by: Gopalgv gopalgv@amazon.com
Authored by: Gopalgv gopalgv@amazon.com
Check List
--signoffFor more information on following Developer Certificate of Origin and signing off your commits, please check here.