prestodb/presto · error · PrestoException

GENERIC_INTERNAL_ERROR

GENERIC_INTERNAL_ERROR

Error message

JsonPath type cannot be serialized

What it means

JsonPathType wraps compiled JSON path expressions used by JSON functions; like JoniRegexpType it is an opaque internal type with no block serialization. createBlockBuilder therefore always throws GENERIC_INTERNAL_ERROR 'JsonPath type cannot be serialized' when the engine tries to materialize a JSONPATH value.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/type/JsonPathType.java:53

        super(new TypeSignature(NAME), JsonPath.class);
    }

    @Override
    public Object getObjectValue(SqlFunctionProperties properties, Block block, int position)
    {
        throw new UnsupportedOperationException();
    }

    @Override
    public void appendTo(Block block, int position, BlockBuilder blockBuilder)
    {
        throw new UnsupportedOperationException();
    }

    @Override
    public BlockBuilder createBlockBuilder(BlockBuilderStatus blockBuilderStatus, int expectedEntries, int expectedBytesPerEntry)
    {
        throw new PrestoException(GENERIC_INTERNAL_ERROR, "JsonPath type cannot be serialized");
    }

    @Override
    public BlockBuilder createBlockBuilder(BlockBuilderStatus blockBuilderStatus, int expectedEntries)
    {
        throw new PrestoException(GENERIC_INTERNAL_ERROR, "JsonPath type cannot be serialized");
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use JSONPATH values only inline as arguments to json functions
  2. Return VARCHAR (the path text) from custom functions instead of JSONPATH
  3. Avoid grouping/joining/exchanging expressions of type JSONPATH

Example fix

// before
SELECT JSON_FORMAT('$[0]') -- materializing a jsonpath value directly
// after
SELECT json_extract(j, '$[0]') -- path used inline inside a json function
Defensive patterns

Strategy: validation

Validate before calling

// JSONPATH values must stay inline; verify output types
// DESCRIBE SELECT <jsonpath expr>; -- JSONPATH in output means the query will fail

Try / catch

try {
    return type.createBlockBuilder(status, expectedEntries, expectedBytes);
} catch (PrestoException e) {
    // JSONPATH cannot be serialized: rewrite query to use json functions inline
    throw e;
}

Prevention

When it happens

Trigger: Any attempt to produce a block of JSONPATH values: selecting a jsonpath expression, exchanging it between stages, or storing it via a connector.

Common situations: Queries that SELECT or alias a JSONPATH value into the output; custom functions returning JSONPATH; attempts to persist json_path values in tables.

Related errors


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