use of org.apache.flink.table.expressions.TypeLiteralExpression in project flink by apache.
the class TryCastConverter method convert.
@Override
public RexNode convert(CallExpression call, CallExpressionConvertRule.ConvertContext context) {
checkArgumentNumber(call, 2);
final FlinkTypeFactory typeFactory = context.getTypeFactory();
final RexNode child = context.toRexNode(call.getChildren().get(0));
final TypeLiteralExpression targetType = (TypeLiteralExpression) call.getChildren().get(1);
RelDataType targetRelDataType = typeFactory.createTypeWithNullability(typeFactory.createFieldTypeFromLogicalType(targetType.getOutputDataType().getLogicalType()), true);
return context.getRelBuilder().getRexBuilder().makeCall(targetRelDataType, FlinkSqlOperatorTable.TRY_CAST, Collections.singletonList(child));
}
use of org.apache.flink.table.expressions.TypeLiteralExpression in project flink by apache.
the class ReinterpretCastConverter method convert.
@Override
public RexNode convert(CallExpression call, CallExpressionConvertRule.ConvertContext context) {
checkArgumentNumber(call, 3);
RexNode child = context.toRexNode(call.getChildren().get(0));
TypeLiteralExpression type = (TypeLiteralExpression) call.getChildren().get(1);
RexNode checkOverflow = context.toRexNode(call.getChildren().get(2));
return context.getRelBuilder().getRexBuilder().makeReinterpretCast(context.getTypeFactory().createFieldTypeFromLogicalType(type.getOutputDataType().getLogicalType().copy(child.getType().isNullable())), child, checkOverflow);
}
use of org.apache.flink.table.expressions.TypeLiteralExpression in project flink by apache.
the class ThrowExceptionConverter method convert.
@Override
public RexNode convert(CallExpression call, CallExpressionConvertRule.ConvertContext context) {
checkArgumentNumber(call, 2);
DataType type = ((TypeLiteralExpression) call.getChildren().get(1)).getOutputDataType();
SqlThrowExceptionFunction function = new SqlThrowExceptionFunction(context.getTypeFactory().createFieldTypeFromLogicalType(fromDataTypeToLogicalType(type)));
return context.getRelBuilder().call(function, context.toRexNode(call.getChildren().get(0)));
}
use of org.apache.flink.table.expressions.TypeLiteralExpression in project flink by apache.
the class CastConverter method convert.
@Override
public RexNode convert(CallExpression call, CallExpressionConvertRule.ConvertContext context) {
checkArgumentNumber(call, 2);
final RexNode child = context.toRexNode(call.getChildren().get(0));
final TypeLiteralExpression targetType = (TypeLiteralExpression) call.getChildren().get(1);
final RelDataType targetRelDataType = context.getTypeFactory().createFieldTypeFromLogicalType(targetType.getOutputDataType().getLogicalType());
return context.getRelBuilder().getRexBuilder().makeAbstractCast(targetRelDataType, child);
}
Aggregations