duckdb_spatial icon indicating copy to clipboard operation
duckdb_spatial copied to clipboard

Null needs to be cast to blob in ST_GeomFromWKB

Open edigonzales opened this issue 1 year ago • 3 comments

SELECT ST_GeomFromWKB(NULL);

throws:

SQL Error: java.sql.SQLException: Binder Error: Could not choose a best candidate function for the function call "ST_GeomFromWKB("NULL")". In order to select one, please add explicit type casts.
	Candidate functions:
	ST_GeomFromWKB(BLOB) -> GEOMETRY
	ST_GeomFromWKB(WKB_BLOB) -> GEOMETRY

Works when NULL is casted to blob:

SELECT ST_GeomFromWKB(NULL::blob);

edigonzales avatar Dec 23 '24 17:12 edigonzales

This is expected, ST_GeomFromWKB is overloaded to work for both BLOB and WKB_BLOB, and a NULL literal has no type.

Maxxen avatar Dec 23 '24 17:12 Maxxen

Seems to work differently in e.g. PostGIS where NULL w/o casting works.

edigonzales avatar Dec 23 '24 17:12 edigonzales

This will be resolved in DuckDB v1.5

Maxxen avatar Oct 24 '25 11:10 Maxxen