{"record":{"id":"8d778ad339464257","repo":"prestodb/presto","slug":"invalid-function-argument-8d778a","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"e.getMessage()","messagePattern":"e\\.getMessage\\(\\)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-geospatial-toolkit/src/main/java/com/facebook/presto/geospatial/type/GeometryType.java","lineNumber":93,"sourceCode":"        if (value == null) {\n            blockBuilder.appendNull();\n            return;\n        }\n        blockBuilder.writeBytes(value, offset, length).closeEntry();\n    }\n\n    @Override\n    public Object getObjectValue(SqlFunctionProperties properties, Block block, int position)\n    {\n        if (block.isNull(position)) {\n            return null;\n        }\n        Slice slice = block.getSlice(position, 0, block.getSliceLength(position));\n        try {\n            return deserialize(slice).asText();\n        }\n        catch (GeometryException e) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);\n        }\n    }\n}\n","sourceCodeStart":75,"sourceCodeEnd":97,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-geospatial-toolkit/src/main/java/com/facebook/presto/geospatial/type/GeometryType.java#L75-L97","documentation":"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.","triggerScenarios":"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.","commonSituations":"Rows written by buggy producers or older Presto versions with incompatible serialization, corruption in external storage (Hive/S3), manual varbinary injection into geometry columns.","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."],"exampleFix":"// before\nSELECT geom FROM corrupt_table; -- throws on bad row\n// after\nSELECT ST_CastToGeometry(ST_ToGeometryFromWKB(wkb)) FROM raw_table WHERE wkb IS NOT NULL; -- rebuild from raw source","handlingStrategy":"validation","validationCode":"SELECT * FROM raw WHERE TRY(ST_GeometryFromText(wkt)) IS NULL; -- find values that would fail to deserialize before writing/reading geometry columns","typeGuard":"boolean isReadableGeometryColumn(Object v) { try { GeometryType.getObjectValueImpl(v); return true; } catch (PrestoException e) { return false; } }","tryCatchPattern":"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; }","preventionTips":["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."],"tags":["geospatial","serialization","corrupt-data"],"backgroundTag":"geometry-deserialization-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}