{"record":{"id":"2a5f15b71e23a16d","repo":"prestodb/presto","slug":"invalid-function-argument-2a5f15","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"%s","messagePattern":"%s","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/geospatial/BingTileFunctions.java","lineNumber":386,"sourceCode":"    @SqlType(GEOMETRY_TYPE_NAME)\n    public static Slice bingTilePolygon(@SqlType(BingTileType.NAME) long input)\n    {\n        BingTile tile = BingTile.decode(input);\n\n        return serialize(tileToEnvelope(tile));\n    }\n\n    @Description(\"Return the parent for a Bing tile\")\n    @ScalarFunction(\"bing_tile_parent\")\n    @SqlType(BingTileType.NAME)\n    public static long bingTileParent(@SqlType(BingTileType.NAME) long input)\n    {\n        BingTile tile = BingTile.decode(input);\n        try {\n            return tile.findParent().encode();\n        }\n        catch (IllegalArgumentException e) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);\n        }\n    }\n\n    @Description(\"Return the parent for the given zoom level for a Bing tile\")\n    @ScalarFunction(\"bing_tile_parent\")\n    @SqlType(BingTileType.NAME)\n    public static long bingTileParent(@SqlType(BingTileType.NAME) long input, @SqlType(StandardTypes.INTEGER) long newZoom)\n    {\n        BingTile tile = BingTile.decode(input);\n        try {\n            return tile.findParent(toIntExact(newZoom)).encode();\n        }\n        catch (IllegalArgumentException e) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);\n        }\n    }\n\n    @Description(\"Return the children for a Bing tile\")","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/geospatial/BingTileFunctions.java#L368-L404","documentation":"bing_tile_parent decodes the input bigint into a BingTile and calls findParent() to get the tile at zoom-1. Any IllegalArgumentException from decoding the input or computing the parent (e.g., the tile is already at zoom level 0 and has no parent) is rethrown as INVALID_FUNCTION_ARGUMENT with the underlying message. The library surfaces the JTS/BingTile validation message directly so the user knows which invariant was violated.","triggerScenarios":"Calling bing_tile_parent(tile) where tile decodes to a zoom-0 tile (no parent exists), or where the bigint is not a valid tile encoding so BingTile.decode throws.","commonSituations":"Iterating up the tile hierarchy in a loop without stopping at zoom 0; passing user-supplied tile IDs of unknown validity; off-by-one logic that requests the parent of a root tile.","solutions":["Check the tile's zoom level is > 0 before calling bing_tile_parent; a zoom-0 tile has no parent.","Verify the input is a valid Bing tile encoding (non-negative, decodable).","Stop hierarchy traversal at zoom level 0.","Use TRY(bing_tile_parent(...)) to tolerate invalid inputs in exploratory queries."],"exampleFix":"// before (SQL)\nSELECT bing_tile_parent(tile) FROM tiles;\n// after\nSELECT bing_tile_parent(tile) FROM tiles WHERE bing_tile_zoom_level(tile) > 0;","handlingStrategy":"validation","validationCode":"-- SQL\nSELECT bing_tile_parent(tile)\nFROM tiles WHERE bing_tile_zoom_level(tile) > 0;","typeGuard":null,"tryCatchPattern":"-- SQL\nSELECT TRY(bing_tile_parent(tile)) FROM tiles;","preventionTips":["Never request a parent of a zoom-0 tile","Check bing_tile_zoom_level(tile) > 0 before traversal","Guard recursion so it terminates at zoom 0"],"tags":["presto","geospatial","bing-tile","sql"],"backgroundTag":"invalid-function-arguments","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"}