prestodb/presto · error · PrestoException

INVALID_FUNCTION_ARGUMENT

INVALID_FUNCTION_ARGUMENT

Error message

%s

What it means

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.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/geospatial/BingTileFunctions.java:386

    @SqlType(GEOMETRY_TYPE_NAME)
    public static Slice bingTilePolygon(@SqlType(BingTileType.NAME) long input)
    {
        BingTile tile = BingTile.decode(input);

        return serialize(tileToEnvelope(tile));
    }

    @Description("Return the parent for a Bing tile")
    @ScalarFunction("bing_tile_parent")
    @SqlType(BingTileType.NAME)
    public static long bingTileParent(@SqlType(BingTileType.NAME) long input)
    {
        BingTile tile = BingTile.decode(input);
        try {
            return tile.findParent().encode();
        }
        catch (IllegalArgumentException e) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);
        }
    }

    @Description("Return the parent for the given zoom level for a Bing tile")
    @ScalarFunction("bing_tile_parent")
    @SqlType(BingTileType.NAME)
    public static long bingTileParent(@SqlType(BingTileType.NAME) long input, @SqlType(StandardTypes.INTEGER) long newZoom)
    {
        BingTile tile = BingTile.decode(input);
        try {
            return tile.findParent(toIntExact(newZoom)).encode();
        }
        catch (IllegalArgumentException e) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);
        }
    }

    @Description("Return the children for a Bing tile")

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check the tile's zoom level is > 0 before calling bing_tile_parent; a zoom-0 tile has no parent.
  2. Verify the input is a valid Bing tile encoding (non-negative, decodable).
  3. Stop hierarchy traversal at zoom level 0.
  4. Use TRY(bing_tile_parent(...)) to tolerate invalid inputs in exploratory queries.

Example fix

// before (SQL)
SELECT bing_tile_parent(tile) FROM tiles;
// after
SELECT bing_tile_parent(tile) FROM tiles WHERE bing_tile_zoom_level(tile) > 0;
Defensive patterns

Strategy: validation

Validate before calling

-- SQL
SELECT bing_tile_parent(tile)
FROM tiles WHERE bing_tile_zoom_level(tile) > 0;

Try / catch

-- SQL
SELECT TRY(bing_tile_parent(tile)) FROM tiles;

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/2a5f15b71e23a16d. Report an issue: GitHub.