use of com.google.zetasql.ZetaSQLType.TypeKind in project beam by apache.
the class ExpressionConverter method convertResolvedCast.
private RexNode convertResolvedCast(ResolvedCast resolvedCast, RexNode input) {
TypeKind fromType = resolvedCast.getExpr().getType().getKind();
TypeKind toType = resolvedCast.getType().getKind();
isCastingSupported(fromType, toType, input);
// nullability of the output type should match that of the input node's type
RelDataType outputType = ZetaSqlCalciteTranslationUtils.toCalciteType(resolvedCast.getType(), input.getType().isNullable(), rexBuilder());
if (isZetaSQLCast(fromType, toType)) {
return rexBuilder().makeCall(outputType, SqlOperators.CAST_OP, ImmutableList.of(input));
} else {
return rexBuilder().makeCast(outputType, input);
}
}
Aggregations