Trait tidb_query_aggr::AggrDefinitionParser[][src]

pub trait AggrDefinitionParser {
    fn check_supported(&self, aggr_def: &Expr) -> Result<()>;

    fn parse(
        &self,
        aggr_def: Expr,
        ctx: &mut EvalContext,
        src_schema: &[FieldType],
        out_schema: &mut Vec<FieldType>,
        out_exp: &mut Vec<RpnExpression>
    ) -> Result<Box<dyn AggrFunction>> { ... }
fn parse_rpn(
        &self,
        _root_expr: Expr,
        _exp: RpnExpression,
        _ctx: &mut EvalContext,
        _src_schema: &[FieldType],
        _out_schema: &mut Vec<FieldType>,
        _out_exp: &mut Vec<RpnExpression>
    ) -> Result<Box<dyn AggrFunction>> { ... } }

Parse a specific aggregate function definition from protobuf.

All aggregate function implementations should include an impl for this trait as well as add a match arm in map_pb_sig_to_aggr_func_parser so that the aggregate function can be actually utilized.

Required methods

fn check_supported(&self, aggr_def: &Expr) -> Result<()>[src]

Checks whether the inner expression of the aggregate function definition is supported. It is ensured that aggr_def.tp maps the current parser instance.

Loading content...

Provided methods

fn parse(
    &self,
    aggr_def: Expr,
    ctx: &mut EvalContext,
    src_schema: &[FieldType],
    out_schema: &mut Vec<FieldType>,
    out_exp: &mut Vec<RpnExpression>
) -> Result<Box<dyn AggrFunction>>
[src]

Parses and transforms the aggregate function definition.

The schema of this aggregate function will be appended in out_schema and the final RPN expression (maybe wrapped by some casting according to types) will be appended in out_exp.

The parser may choose particular aggregate function implementation based on the data type, so schema is also needed in case of data type depending on the column.

Panic

May panic if the aggregate function definition is not supported by this parser.

fn parse_rpn(
    &self,
    _root_expr: Expr,
    _exp: RpnExpression,
    _ctx: &mut EvalContext,
    _src_schema: &[FieldType],
    _out_schema: &mut Vec<FieldType>,
    _out_exp: &mut Vec<RpnExpression>
) -> Result<Box<dyn AggrFunction>>
[src]

Loading content...

Implementors

impl AggrDefinitionParser for AggrFnDefinitionParserAvg[src]

impl AggrDefinitionParser for AggrFnDefinitionParserCount[src]

impl AggrDefinitionParser for AggrFnDefinitionParserFirst[src]

impl AggrDefinitionParser for AggrFnDefinitionParserSum[src]

impl AggrDefinitionParser for AllAggrDefinitionParser[src]

fn check_supported(&self, aggr_def: &Expr) -> Result<()>[src]

Checks whether the aggregate function definition is supported.

fn parse(
    &self,
    aggr_def: Expr,
    ctx: &mut EvalContext,
    src_schema: &[FieldType],
    out_schema: &mut Vec<FieldType>,
    out_exp: &mut Vec<RpnExpression>
) -> Result<Box<dyn AggrFunction>>
[src]

Parses and transforms the aggregate function definition to generate corresponding AggrFunction instance.

Panic

May panic if the aggregate function definition is not supported.

impl<E: Extremum> AggrDefinitionParser for AggrFnDefinitionParserExtremum<E>[src]

impl<T: BitOp> AggrDefinitionParser for AggrFnDefinitionParserBitOp<T>[src]

impl<V: VarianceType> AggrDefinitionParser for AggrFnDefinitionParserVariance<V>[src]

Loading content...