Search in sources :

Example 1 with TypeKind

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);
    }
}
Also used : TypeKind(com.google.zetasql.ZetaSQLType.TypeKind) RelDataType(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType)

Aggregations

TypeKind (com.google.zetasql.ZetaSQLType.TypeKind)1 RelDataType (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType)1