flow/expr/
signature.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Function signature, useful for type checking and function resolution.
16
17use datatypes::data_type::ConcreteDataType;
18use serde::{Deserialize, Serialize};
19use smallvec::SmallVec;
20
21/// Function signature
22///
23/// TODO(discord9): use `common_query::signature::Signature` crate
24#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, Hash)]
25pub struct Signature {
26    /// the input types, usually not great than two input arg
27    pub input: SmallVec<[ConcreteDataType; 2]>,
28    /// Output type
29    pub output: ConcreteDataType,
30    /// Generic function
31    pub generic_fn: GenericFn,
32}
33
34/// Generic function category
35#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, Hash)]
36pub enum GenericFn {
37    // aggregate func
38    Max,
39    Min,
40    Sum,
41    Count,
42    Any,
43    All,
44    // unary func
45    Not,
46    IsNull,
47    IsTrue,
48    IsFalse,
49    StepTimestamp,
50    Cast,
51    // binary func
52    Eq,
53    NotEq,
54    Lt,
55    Lte,
56    Gt,
57    Gte,
58    Add,
59    Sub,
60    Mul,
61    Div,
62    Mod,
63    // variadic func
64    And,
65    Or,
66    // unmaterized func
67    Now,
68    CurrentSchema,
69    TumbleWindow,
70}