use of io.trino.util.JsonUtil.BlockBuilderAppender in project trino by trinodb.
the class JsonToArrayCast method specialize.
@Override
protected ScalarFunctionImplementation specialize(BoundSignature boundSignature) {
checkArgument(boundSignature.getArity() == 1, "Expected arity to be 1");
ArrayType arrayType = (ArrayType) boundSignature.getReturnType();
checkCondition(canCastFromJson(arrayType), INVALID_CAST_ARGUMENT, "Cannot cast JSON to %s", arrayType);
BlockBuilderAppender arrayAppender = BlockBuilderAppender.createBlockBuilderAppender(arrayType);
MethodHandle methodHandle = METHOD_HANDLE.bindTo(arrayType).bindTo(arrayAppender);
return new ChoicesScalarFunctionImplementation(boundSignature, NULLABLE_RETURN, ImmutableList.of(NEVER_NULL), methodHandle);
}
use of io.trino.util.JsonUtil.BlockBuilderAppender in project trino by trinodb.
the class JsonToMapCast method specialize.
@Override
protected ScalarFunctionImplementation specialize(BoundSignature boundSignature) {
checkArgument(boundSignature.getArity() == 1, "Expected arity to be 1");
MapType mapType = (MapType) boundSignature.getReturnType();
checkCondition(canCastFromJson(mapType), INVALID_CAST_ARGUMENT, "Cannot cast JSON to %s", mapType);
BlockBuilderAppender mapAppender = createBlockBuilderAppender(mapType);
MethodHandle methodHandle = METHOD_HANDLE.bindTo(mapType).bindTo(mapAppender);
return new ChoicesScalarFunctionImplementation(boundSignature, NULLABLE_RETURN, ImmutableList.of(NEVER_NULL), methodHandle);
}
use of io.trino.util.JsonUtil.BlockBuilderAppender in project trino by trinodb.
the class JsonToRowCast method specialize.
@Override
protected ScalarFunctionImplementation specialize(BoundSignature boundSignature) {
RowType rowType = (RowType) boundSignature.getReturnType();
checkCondition(canCastFromJson(rowType), INVALID_CAST_ARGUMENT, "Cannot cast JSON to %s", rowType);
BlockBuilderAppender fieldAppender = createBlockBuilderAppender(rowType);
MethodHandle methodHandle = METHOD_HANDLE.bindTo(rowType).bindTo(fieldAppender);
return new ChoicesScalarFunctionImplementation(boundSignature, NULLABLE_RETURN, ImmutableList.of(NEVER_NULL), methodHandle);
}
Aggregations