Skip to content

Is there a pure DuckDB way to order GeoParquet output spatially? #419

Answered by Maxxen
cholmes asked this question in Q&A
Discussion options

You must be logged in to vote

Hello! Unfortunately, DuckDB does not support overriding the comparison operators (used to sort) for custom types, meaning ORDER BY <geometry> will just order based on the lexical order of the bytes in the internal binary representation. The r-tree index is completely separate from ordering. I know that other databases (like Postgres) sometimes can perform an index scan instead of explicitly sorting when executing an order-by, but this requires the ordering criteria to map to the physical order of the index. In the case of R-Trees, I can't think of any way that would work.

Perhaps there could be a "dummy" scalar function the optimizer could detect to do this if the column is r-tree indexe…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@cholmes
Comment options

@Maxxen
Comment options

Answer selected by cholmes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants