Search in sources :

Example 1 with RexNodeExpression

use of org.apache.flink.table.planner.expressions.RexNodeExpression in project flink by apache.

the class ResolvedExpressionJsonDeserializer method deserializeRexNodeExpression.

private ResolvedExpression deserializeRexNodeExpression(ObjectNode jsonNode, ObjectCodec codec, DeserializationContext ctx) throws IOException {
    RexNode node = ctx.readValue(jsonNode.get(REX_NODE).traverse(codec), RexNode.class);
    String serializableString = jsonNode.get(SERIALIZABLE_STRING).asText();
    return new RexNodeExpression(node, DataTypes.of(FlinkTypeFactory.toLogicalType(node.getType())), node.toString(), serializableString);
}
Also used : RexNodeExpression(org.apache.flink.table.planner.expressions.RexNodeExpression) RexNode(org.apache.calcite.rex.RexNode)

Example 2 with RexNodeExpression

use of org.apache.flink.table.planner.expressions.RexNodeExpression in project flink by apache.

the class ParserImpl method parseSqlExpression.

@Override
public ResolvedExpression parseSqlExpression(String sqlExpression, RowType inputRowType, @Nullable LogicalType outputType) {
    final SqlExprToRexConverter sqlExprToRexConverter = sqlExprToRexConverterFactory.create(inputRowType, outputType);
    final RexNode rexNode = sqlExprToRexConverter.convertToRexNode(sqlExpression);
    final LogicalType logicalType = FlinkTypeFactory.toLogicalType(rexNode.getType());
    // expand expression for serializable expression strings similar to views
    final String sqlExpressionExpanded = sqlExprToRexConverter.expand(sqlExpression);
    return new RexNodeExpression(rexNode, TypeConversions.fromLogicalToDataType(logicalType), sqlExpression, sqlExpressionExpanded);
}
Also used : RexNodeExpression(org.apache.flink.table.planner.expressions.RexNodeExpression) SqlExprToRexConverter(org.apache.flink.table.planner.calcite.SqlExprToRexConverter) LogicalType(org.apache.flink.table.types.logical.LogicalType) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

RexNode (org.apache.calcite.rex.RexNode)2 RexNodeExpression (org.apache.flink.table.planner.expressions.RexNodeExpression)2 SqlExprToRexConverter (org.apache.flink.table.planner.calcite.SqlExprToRexConverter)1 LogicalType (org.apache.flink.table.types.logical.LogicalType)1