Skip to content

Read a geometry set as text as every set reads - #463

Merged
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/geometry-set-text-cast
Oct 18, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/geometry-set-text-cast

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

geomset and geogset cast to VARCHAR through SetFunctions::Set_to_text, the cast every other set
type takes in SetTypes::RegisterCastFunctions, which writes the set with MEOS's set_out: each
element as its hexadecimal extended WKB, as MobilityDB's geomset::text writes it.
SpatialSetType::RegisterCastFunctions registers these two beside the casts from VARCHAR it holds.

Witness: on main SELECT (geomset '{Point(1 1), Point(2 2)}')::VARCHAR answers the raw bytes of
the value, \xE0\x02\x00\x00+*\x12\x00..., DuckDB's cast of a BLOB, where MobilityDB answers
{"0101000000000000000000F03F000000000000F03F", "010100000000000000000000400000000000000040"};
here MobilityDuck answers MobilityDB's text.

Measured: test/sql/geoset.test states a geometry set, a geography set and a geometry set with an
SRID, each read as text, against the text MobilityDB answers for the same values.

Why: a cast DuckDB applies wherever a VARCHAR is wanted shows a geometry set as its bytes, where
every other set shows its values.

geomset and geogset cast to VARCHAR through SetFunctions::Set_to_text, the cast every other set
type takes in SetTypes::RegisterCastFunctions, which writes the set with MEOS's set_out: each
element as its hexadecimal extended WKB, as MobilityDB's geomset::text writes it.
SpatialSetType::RegisterCastFunctions registers these two beside the casts from VARCHAR it holds.

Witness: on main `SELECT (geomset '{Point(1 1), Point(2 2)}')::VARCHAR` answers the raw bytes of
the value, `\xE0\x02\x00\x00+*\x12\x00...`, DuckDB's cast of a BLOB, where MobilityDB answers
{"0101000000000000000000F03F000000000000F03F", "010100000000000000000000400000000000000040"};
here MobilityDuck answers MobilityDB's text.

Measured: test/sql/geoset.test states a geometry set, a geography set and a geometry set with an
SRID, each read as text, against the text MobilityDB answers for the same values.

Why: a cast DuckDB applies wherever a VARCHAR is wanted shows a geometry set as its bytes, where
every other set shows its values.
@estebanzimanyi
estebanzimanyi merged commit 5d3ab06 into MobilityDB:main Oct 18, 2026
9 checks passed
@estebanzimanyi
estebanzimanyi deleted the fix/geometry-set-text-cast branch October 18, 2026 14:27
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.

1 participant