Adds ret_field_type
@@ -95,4 +95,17 @@ impl AsRef<[RpnExpressionNode]> for RpnExpression {
}
}
+impl RpnExpression {
+ /// Gets the field type of the return value.
+ pub fn ret_field_type<'a>(&'a self, schema: &'a [FieldType]) -> &'a FieldType {
+ assert!(!self.0.is_empty());
+ let last_node = self.0.last().unwrap();
+ match last_node {
+ RpnExpressionNode::FnCall { field_type, .. } => field_type,
+ RpnExpressionNode::Constant { field_type, .. } => field_type,
+ RpnExpressionNode::ColumnRef { offset } => &schema[*offset],
+ }
+ }
+}
+
// For `RpnExpression::eval`, see `expr_eval` file.
