Skip to content

feat(python/sedonadb): normalize geometry WKT expected values in harness#845

Open
oglego wants to merge 1 commit into
apache:mainfrom
oglego:feat/wkt-formatting
Open

feat(python/sedonadb): normalize geometry WKT expected values in harness#845
oglego wants to merge 1 commit into
apache:mainfrom
oglego:feat/wkt-formatting

Conversation

@oglego
Copy link
Copy Markdown
Contributor

@oglego oglego commented May 15, 2026

Summary

Fixes #815 - formatting-only failures in Python tests that use WKT as an expected value by normalizing geometry WKT in the Python test harness before comparison.

Problem

Some Python tests compare query results against expected WKT strings using assert_query_result(). When the query returns a geometry value, the Python harness converts that geometry to WKT before comparing tuple results.

The issue is that equivalent WKT can be formatted differently depending on which writer produced it. In practice, this showed up as whitespace-only differences, such as whether spaces appear after commas:

Expected:
POLYGON Z ((0 0 5,0 1 5,1 1 5,1 0 5,0 0 5))

Got:
POLYGON Z ((0 0 5, 0 1 5, 1 1 5, 1 0 5, 0 0 5))

These failures are not about the geometry result itself, they come from string formatting differences.

What changed

  • Updated the Python test harness to canonicalize WKT only for geometry-typed result columns during tuple-based comparisons
  • Left non-geometry string columns on exact string comparison
  • Added a regression test that verifies this distinction:
    • geometry results with spacing-only WKT differences compare equal
    • plain string results with the same spacing differences still fail

Why this approach

This keeps geometry tests focused on geometry semantics rather than renderer-specific text formatting.

The important detail is scope: we do not normalize all strings globally. Only columns that are actually typed as geometry are canonicalized. That avoids masking real regressions in plain-text outputs while still fixing the formatting-only failures that motivated this change.

Testing

  • pytest -q python/sedonadb/tests/test_testing.py
  • pytest -q python/sedonadb/tests/functions/test_functions.py

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.

python/sedonadb: Investigate formatting issues when using WKT as an expected value

1 participant