Skip to content

[DO NOT MERGE] Linestring : TDS Receiver and CAST geometry from bytea#3813

Closed
Mohitraj-g wants to merge 22 commits intobabelfish-for-postgresql:BABEL_5_X_DEVfrom
Mohitraj-g:babel-5767
Closed

[DO NOT MERGE] Linestring : TDS Receiver and CAST geometry from bytea#3813
Mohitraj-g wants to merge 22 commits intobabelfish-for-postgresql:BABEL_5_X_DEVfrom
Mohitraj-g:babel-5767

Conversation

@Mohitraj-g
Copy link
Copy Markdown
Contributor

@Mohitraj-g Mohitraj-g commented Jun 9, 2025

LINESTRING SUPPORT

This PR implements LINESTRING geometry type support in Babelfish, expanding beyond the current POINT-only implementation.

Key Changes:

  1. Parser Modifications

    • Added LINESTRING syntax support
    • Implemented handling of varying point dimensions within LINESTRING
    • Added normalization of points to highest dimension using NaN values
  2. TDS Layer Enhancements

    • TDS Sender:

      • Added coordinate reordering from PostGIS (x1 y1 z1 m1) to TSQL format (x1 y1 x2 y2 z1 z2 m1 m2)
      • Implemented validity byte handling
      • Added bounding box processing
    • TDS Receiver:

      • Implemented reverse coordinate ordering
      • Added manual bounding box calculation
      • Added bbox flag setting for PostGIS format
  3. CAST Operations

    • CharToGeom/CharToGeog:

      • Added LINESTRING WKT parsing
      • Implemented dimension normalization
    • GeomToChar/GeogToChar:

      • Added NaN coordinate omission
      • Implemented dimension-based formatting
    • GeomToByte/ByteToGeom:

      • Added coordinate order conversion
      • Implemented validity flag handling
  4. Function change:

  • Included STIsValid within seven functions: STDistance, STDisjoint, STContains, STEquals, STIntersects, STArea, STDimension

Testing:

  • Added unit tests for parser
  • Added TDS protocol tests
  • Added CAST operation tests

Issues Resolved

BABEL-5766
BABEL-5767
BABEL-5768

Signed-off by: Mohit Raj mrxmohit@amazon.com

Authored by: Mohit Raj mrxmohit@amazon.com

Test Scenarios Covered

  • Use case based - Yes

  • Boundary conditions - Yes

  • Arbitrary inputs - Yes

  • Negative test cases - Yes

  • Minor version upgrade tests -

  • Major version upgrade tests -

  • Performance tests -

  • Tooling impact -

  • Client tests -

Check List

  • Commits are signed per the DCO using --signoff

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.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Jun 9, 2025

Pull Request Test Coverage Report for Build 15893621994

Details

  • 726 of 747 (97.19%) changed or added relevant lines in 5 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 76.019%

Changes Missing Coverage Covered Lines Changed/Added Lines %
contrib/babelfishpg_common/src/geo.c 117 120 97.5%
contrib/babelfishpg_common/src/spatialtypes.c 272 280 97.14%
contrib/babelfishpg_tds/src/backend/tds/tdstypeio.c 299 309 96.76%
Files with Coverage Reduction New Missed Lines %
contrib/babelfishpg_tds/src/backend/tds/tdscomm.c 2 76.23%
Totals Coverage Status
Change from base Build 15889588684: 0.2%
Covered Lines: 50000
Relevant Lines: 65773

💛 - Coveralls

@Mohitraj-g Mohitraj-g changed the title TDS sender and parser changes Support Linestring for Geospatial Datatypes Jun 10, 2025
@Mohitraj-g Mohitraj-g changed the title Support Linestring for Geospatial Datatypes Linestring[Part 2] : TDS Receiver ansdCAST geometry from bytea Sep 2, 2025
@Mohitraj-g Mohitraj-g changed the title Linestring[Part 2] : TDS Receiver ansdCAST geometry from bytea Linestring[Part 2] : TDS Receiver and CAST geometry from bytea Sep 2, 2025
@Mohitraj-g Mohitraj-g changed the title Linestring[Part 2] : TDS Receiver and CAST geometry from bytea [DO NOT MERGE] Linestring : TDS Receiver and CAST geometry from bytea Sep 8, 2025
@Mohitraj-g Mohitraj-g closed this Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants