presto-main/src/main/java/io/prestosql/operator/scalar/JsonToRowCast.java/JsonToRowCast/specialize
class JsonToRowCast:    @Override
    public ScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, Metadata metadata)
    {
        checkArgument(arity == 1, "Expected arity to be 1");
        RowType rowType = (RowType) boundVariables.getTypeVariable("T");
        checkCondition(canCastFromJson(rowType), INVALID_CAST_ARGUMENT, "Cannot cast JSON to %s", rowType);

        List<Field> rowFields = rowType.getFields();
        BlockBuilderAppender[] fieldAppenders = rowFields.stream()
                .map(rowField -> createBlockBuilderAppender(rowField.getType()))
                .toArray(BlockBuilderAppender[]::new);
        MethodHandle methodHandle = METHOD_HANDLE.bindTo(rowType).bindTo(fieldAppenders).bindTo(getFieldNameToIndex(rowFields));
        return new ScalarFunctionImplementation(
                true,
                ImmutableList.of(valueTypeArgumentProperty(RETURN_NULL_ON_NULL)),
                methodHandle);
    }