prestodb/presto · error · PrestoException
INVALID_FUNCTION_ARGUMENT
INVALID_FUNCTION_ARGUMENT
Error message
e.getMessage()
What it means
EsriGeometrySerde.deserialize wraps GeometryException raised while decoding a serialized geometry blob and rethrows it as INVALID_FUNCTION_ARGUMENT with the original message. It means the binary value in a geometry-typed column/argument could not be deserialized to an OGCGeometry.
Source
Thrown at presto-geospatial-toolkit/src/main/java/com/facebook/presto/geospatial/serde/EsriGeometrySerde.java:179
{
requireNonNull(shape, "shape is null");
BasicSliceInput input = shape.getInput();
verify(input.available() > 0);
return GeometrySerializationType.getForCode(input.readByte());
}
public static OGCGeometry deserialize(Slice shape)
{
requireNonNull(shape, "shape is null");
BasicSliceInput input = shape.getInput();
verify(input.available() > 0);
int length = input.available() - 1;
GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte());
try {
return readGeometry(input, shape, type, length);
}
catch (GeometryException e) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);
}
}
private static OGCGeometry readGeometry(BasicSliceInput input, Slice inputSlice, GeometrySerializationType type, int length)
{
switch (type) {
case POINT:
return readPoint(input);
case MULTI_POINT:
case LINE_STRING:
case MULTI_LINE_STRING:
case POLYGON:
case MULTI_POLYGON:
return readSimpleGeometry(input, inputSlice, type, length);
case GEOMETRY_COLLECTION:
return readGeometryCollection(input, inputSlice);
case ENVELOPE:
return createFromEsriGeometry(readEnvelope(input), false);View on GitHub (pinned to 55bb57d202)
Solutions
- Re-serialize the geometry through Presto itself: ST_AsBinary/ST_GeometryFromText round-trip to produce a valid blob.
- Validate the source data's encoding matches the expected Presto geometry serialization.
- Locate and quarantine the corrupt row(s) by scanning with ST_IsEmpty/ST_GeometryType.
- Fix the upstream producer to emit Presto-compatible geometry varbinary.
Example fix
// before INSERT INTO geo_table SELECT raw_bytes FROM staged_data; -- arbitrary varbinary // after INSERT INTO geo_table SELECT ST_AsBinary(ST_GeometryFromText(wkt)) FROM staged_data; -- valid geometry blob
Defensive patterns
Strategy: validation
Validate before calling
-- pre-check that geometry values decode SELECT * FROM t WHERE TRY(ST_GeometryFromText(ST_AsText(geom))) IS NULL; -- find un-decodable rows before real query
Type guard
boolean isDecodableGeometry(byte[] blob) { try { EsriGeometrySerde.deserialize(wrap(blob)); return true; } catch (Exception e) { return false; } } Try / catch
try { rows = query(); } catch (PrestoException e) { if ("INVALID_FUNCTION_ARGUMENT".equals(e.getErrorCode().getName())) { quarantineBadRows(); return safeQuery(); } throw e; } Prevention
- Write geometries only via ST_AsBinary/ST_AsText from Presto.
- Validate serialized blobs at ingestion.
- Avoid mixing serialization formats across Presto versions.
- Checksum/verify geometry data copied between systems.
When it happens
Trigger: Reading a geometry column whose bytes violate the Esri serialization format (bad type code byte, truncated slice, wrong length), or manually inserting/passing invalid binary as a geometry.
Common situations: ETL jobs writing geometries with a different serialization (e.g. JTS-flavored) into Esri-decoded columns, truncated values from external storage, corrupted WKB from upstream tools.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/265fe20fa6c13739.
Report an issue: GitHub.