prestodb/presto · error · PrestoException
INVALID_FUNCTION_ARGUMENT
INVALID_FUNCTION_ARGUMENT
Error message
%s
What it means
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.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/geospatial/BingTileUtils.java:92
static void checkQuadKey(@SqlType(StandardTypes.VARCHAR) Slice quadkey)
{
checkCondition(quadkey.length() <= MAX_ZOOM_LEVEL, QUAD_KEY_TOO_LONG);
}
static void checkLatitude(double latitude, String errorMessage)
{
checkCondition(latitude >= MIN_LATITUDE && latitude <= MAX_LATITUDE, errorMessage);
}
static void checkLongitude(double longitude, String errorMessage)
{
checkCondition(longitude >= MIN_LONGITUDE && longitude <= MAX_LONGITUDE, errorMessage);
}
static void checkCondition(boolean condition, String formatString, Object... args)
{
if (!condition) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format(formatString, args));
}
}
/**
* Return the longitude (in degrees) of the west edge of the tile.
*/
public static double tileXToLongitude(int tileX, int zoomLevel)
{
int mapTileSize = 1 << zoomLevel;
double x = (clip(tileX, 0, mapTileSize) / mapTileSize) - 0.5;
return 360 * x;
}
/**
* Return the latitude (in degrees) of the north edge of the tile.
*/
public static double tileYToLatitude(int tileY, int zoomLevel)
{View on GitHub (pinned to 55bb57d202)
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.
Example fix
// before (SQL) SELECT bing_tile(x, y, zoom) FROM points; // after SELECT bing_tile(x, y, zoom) FROM points WHERE zoom BETWEEN 0 AND 31 AND x >= 0 AND x < pow(2, zoom) AND y >= 0 AND y < pow(2, zoom);
Defensive patterns
Strategy: validation
Validate before calling
-- SQL: validate all Bing tile inputs SELECT * FROM t WHERE zoom BETWEEN 0 AND 31 AND lat BETWEEN -85.05112878 AND 85.05112878 AND lon BETWEEN -180 AND 180;
Try / catch
-- SQL SELECT TRY(bing_tile_at(lat, lon, zoom)) FROM t;
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- INVALID_CAST_ARGUMENT
- INVALID_FUNCTION_ARGUMENT
- INVALID_FUNCTION_ARGUMENT
- INVALID_TABLE_PROPERTY
- Invalid decimal value '{stringValue}'
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/83b7e5a47fd51bf0.
Report an issue: GitHub.