prestodb/presto · error · PrestoException
INVALID_FUNCTION_ARGUMENT
INVALID_FUNCTION_ARGUMENT
Error message
e.getMessage()
What it means
GeometryType.getObjectValue converts a stored geometry slice to its text form via deserialize(...).asText(); a GeometryException during that conversion is rethrown as INVALID_FUNCTION_ARGUMENT. It means a binary value stored in a geometry column cannot be rendered as geometry text, i.e. the stored blob is invalid.
Source
Thrown at presto-geospatial-toolkit/src/main/java/com/facebook/presto/geospatial/type/GeometryType.java:93
if (value == null) {
blockBuilder.appendNull();
return;
}
blockBuilder.writeBytes(value, offset, length).closeEntry();
}
@Override
public Object getObjectValue(SqlFunctionProperties properties, Block block, int position)
{
if (block.isNull(position)) {
return null;
}
Slice slice = block.getSlice(position, 0, block.getSliceLength(position));
try {
return deserialize(slice).asText();
}
catch (GeometryException e) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);
}
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Identify the corrupt rows by reading the underlying varbinary and attempting ST_GeometryFromText(ST_AsText(...)) per row.
- Rewrite the column: recreate valid geometries from WKT/WKB source data.
- Verify the writer version's serialization matches the reader; upgrade/repair table with a rewrite.
- Add an ingestion-time validation step that deserializes each geometry before persisting.
Example fix
// before SELECT geom FROM corrupt_table; -- throws on bad row // after SELECT ST_CastToGeometry(ST_ToGeometryFromWKB(wkb)) FROM raw_table WHERE wkb IS NOT NULL; -- rebuild from raw source
Defensive patterns
Strategy: validation
Validate before calling
SELECT * FROM raw WHERE TRY(ST_GeometryFromText(wkt)) IS NULL; -- find values that would fail to deserialize before writing/reading geometry columns
Type guard
boolean isReadableGeometryColumn(Object v) { try { GeometryType.getObjectValueImpl(v); return true; } catch (PrestoException e) { return false; } } Try / catch
try { rows = connection.query("SELECT geom FROM t"); } catch (PrestoException e) { if ("INVALID_FUNCTION_ARGUMENT".equals(e.getErrorCode().getName())) { rebuildColumnFromRawSource(); return connection.query("SELECT geom FROM t"); } throw e; } Prevention
- Never insert raw varbinary into geometry columns; always go through ST_* constructors.
- Validate each geometry deserializes before persisting in ETL.
- Keep reader/writer Presto versions compatible for geometry tables.
- Rewrite corrupted tables from raw WKT/WKB sources.
When it happens
Trigger: SELECTing/reading a geometry column that contains bytes not conforming to the Presto geometry serialization (bad type code, truncated data), so the block's value fails to deserialize when producing output.
Common situations: Rows written by buggy producers or older Presto versions with incompatible serialization, corruption in external storage (Hive/S3), manual varbinary injection into geometry columns.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/8d778ad339464257.
Report an issue: GitHub.