use of io.trino.util.JsonUtil.ObjectKeyProvider in project trino by trinodb.
the class MapToJsonCast method specialize.
@Override
public ScalarFunctionImplementation specialize(BoundSignature boundSignature) {
MapType mapType = (MapType) boundSignature.getArgumentType(0);
Type keyType = mapType.getKeyType();
Type valueType = mapType.getValueType();
checkCondition(canCastToJson(mapType), INVALID_CAST_ARGUMENT, "Cannot cast %s to JSON", mapType);
ObjectKeyProvider provider = ObjectKeyProvider.createObjectKeyProvider(keyType);
JsonGeneratorWriter writer = JsonGeneratorWriter.createJsonGeneratorWriter(valueType, legacyRowToJson);
MethodHandle methodHandle = METHOD_HANDLE.bindTo(provider).bindTo(writer);
return new ChoicesScalarFunctionImplementation(boundSignature, FAIL_ON_NULL, ImmutableList.of(NEVER_NULL), methodHandle);
}
Aggregations