{"record":{"id":"83b7e5a47fd51bf0","repo":"prestodb/presto","slug":"invalid-function-argument-83b7e5","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/BingTileUtils.java","lineNumber":92,"sourceCode":"    static void checkQuadKey(@SqlType(StandardTypes.VARCHAR) Slice quadkey)\n    {\n        checkCondition(quadkey.length() <= MAX_ZOOM_LEVEL, QUAD_KEY_TOO_LONG);\n    }\n\n    static void checkLatitude(double latitude, String errorMessage)\n    {\n        checkCondition(latitude >= MIN_LATITUDE && latitude <= MAX_LATITUDE, errorMessage);\n    }\n\n    static void checkLongitude(double longitude, String errorMessage)\n    {\n        checkCondition(longitude >= MIN_LONGITUDE && longitude <= MAX_LONGITUDE, errorMessage);\n    }\n\n    static void checkCondition(boolean condition, String formatString, Object... args)\n    {\n        if (!condition) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format(formatString, args));\n        }\n    }\n\n    /**\n     * Return the longitude (in degrees) of the west edge of the tile.\n     */\n    public static double tileXToLongitude(int tileX, int zoomLevel)\n    {\n        int mapTileSize = 1 << zoomLevel;\n        double x = (clip(tileX, 0, mapTileSize) / mapTileSize) - 0.5;\n        return 360 * x;\n    }\n\n    /**\n     * Return the latitude (in degrees) of the north edge of the tile.\n     */\n    public static double tileYToLatitude(int tileY, int zoomLevel)\n    {","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/geospatial/BingTileUtils.java#L74-L110","documentation":"BingTileUtils.checkCondition is the shared guard used by checkZoomLevel, checkCoordinate, checkQuadKey, checkLatitude, and checkLongitude. When a validated condition is false it throws INVALID_FUNCTION_ARGUMENT with a formatted message. It is the central input validator for all Bing tile functions, covering zoom ranges (0-31), x/y coordinate bounds for a zoom, quadkey validity, and lat/lon ranges.","triggerScenarios":"Any bing_tile_* call with: zoom level outside 0-31; x or y coordinate outside [0, 2^zoom - 1]; a malformed quadkey string; latitude outside [-85.05112878, 85.05112878] or longitude outside [-180, 180] passed to bing_tiles_around or geometry_to_bing_tiles helpers.","commonSituations":"Lat/lon columns in a different CRS or swapped lat/lon order; zoom levels from user input or config with no range check; quadkeys with invalid characters or wrong length; coordinates from data covering poles beyond Web Mercator range.","solutions":["Validate zoom level is an integer between 0 and 31 before calling.","Validate latitude is within Web Mercator bounds (-85.05112878 to 85.05112878) and longitude within [-180, 180].","Check x/y satisfy 0 <= coord < 2^zoom for the given zoom.","Ensure quadkeys contain only characters 0-3 and have length equal to the zoom level.","Filter out-of-range rows before applying tile functions."],"exampleFix":"// before (SQL)\nSELECT bing_tile(x, y, zoom) FROM points;\n// after\nSELECT bing_tile(x, y, zoom) FROM points\nWHERE zoom BETWEEN 0 AND 31\n  AND x >= 0 AND x < pow(2, zoom) AND y >= 0 AND y < pow(2, zoom);","handlingStrategy":"validation","validationCode":"-- SQL: validate all Bing tile inputs\nSELECT * FROM t\nWHERE zoom BETWEEN 0 AND 31\n  AND lat BETWEEN -85.05112878 AND 85.05112878\n  AND lon BETWEEN -180 AND 180;","typeGuard":null,"tryCatchPattern":"-- SQL\nSELECT TRY(bing_tile_at(lat, lon, zoom)) FROM t;","preventionTips":["Validate lat/lon against Web Mercator bounds before tile calls","Check zoom is 0-31 from any user/config source","Verify quadkeys are 0-3 characters only with length == zoom","Confirm lat/lon column order isn't swapped"],"tags":["presto","geospatial","bing-tile","input-validation","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"}