use of io.confluent.ksql.execution.interpreter.terms.CastTerm.CastFunction in project ksql by confluentinc.
the class CastInterpreter method castToMapFunction.
public static CastFunction castToMapFunction(final SqlType from, final SqlType to, final KsqlConfig config) {
if (from.baseType() == SqlBaseType.MAP && to.baseType() == SqlBaseType.MAP) {
final SqlMap fromMap = (SqlMap) from;
final SqlMap toMap = (SqlMap) to;
final CastFunction keyCastFunction = castFunction(fromMap.getKeyType(), toMap.getKeyType(), config);
final CastFunction valueCastFunction = castFunction(fromMap.getValueType(), toMap.getValueType(), config);
return o -> CastEvaluator.castMap((Map<?, ?>) o, keyCastFunction::cast, valueCastFunction::cast);
}
throw new KsqlException("Unsupported cast to " + to + ": " + from);
}
use of io.confluent.ksql.execution.interpreter.terms.CastTerm.CastFunction in project ksql by confluentinc.
the class CastInterpreter method castToArrayFunction.
public static CastFunction castToArrayFunction(final SqlType from, final SqlType to, final KsqlConfig config) {
if (from.baseType() == SqlBaseType.ARRAY && to.baseType() == SqlBaseType.ARRAY) {
final SqlArray fromArray = (SqlArray) from;
final SqlArray toArray = (SqlArray) to;
final CastFunction itemCastFunction = castFunction(fromArray.getItemType(), toArray.getItemType(), config);
return o -> CastEvaluator.castArray((List<?>) o, itemCastFunction::cast);
}
throw new KsqlException(getErrorMessage(from, to));
}
Aggregations