pub enum Type {
Unspecified,
Number,
String,
Bool,
Array(Box<Type>),
Record(BTreeMap<String, Type>),
Subject,
App {
args: FunArgs,
result: Box<Type>,
aggregate: bool,
},
Date,
Time,
DateTime,
Custom(String),
}Expand description
Type information for expressions.
This enum represents the type of an expression in the E
Variants§
Unspecified
Type has not been determined yet
Number
Numeric type (f64)
String
String type
Bool
Boolean type
Array(Box<Type>)
Array type
Record(BTreeMap<String, Type>)
Record (object) type
Subject
Subject pattern type
App
Function type with support for optional parameters.
The args field uses FunArgs to support both required and optional parameters.
Optional parameters are indicated when args.needed < args.values.len().
§Examples
use eventql_parser::prelude::{Type, FunArgs};
// Function with all required parameters: (number, string) -> boolean
let all_required = Type::App {
args: vec![Type::Number, Type::String].into(),
result: Box::new(Type::Bool),
aggregate: false,
};
// Aggregate function with optional parameter: (boolean?) => number
let with_optional = Type::App {
args: FunArgs {
values: vec![Type::Bool],
needed: 0, // All parameters are optional
},
result: Box::new(Type::Number),
aggregate: true,
};Fields
Date
Date type (e.g., 2026-01-03)
Used when a field is explicitly converted to a date using the AS DATE syntax.
Time
Time type (e.g., 13:45:39)
Used when a field is explicitly converted to a time using the AS TIME syntax.
DateTime
DateTime type (e.g., 2026-01-01T13:45:39Z)
Used when a field is explicitly converted to a datetime using the AS DATETIME syntax.
Custom(String)
Custom type not defined in the EventQL reference
Used when a field is converted to a custom type registered in AnalysisOptions::custom_types.
The string contains the custom type name as it appears in the query.
§Examples
use eventql_parser::{parse_query, prelude::AnalysisOptions};
let query = parse_query("FROM e IN events PROJECT INTO { ts: e.data.timestamp as CustomTimestamp }").unwrap();
let options = AnalysisOptions::default().add_custom_type("CustomTimestamp");
let typed_query = query.run_static_analysis(&options).unwrap();Implementations§
Trait Implementations§
Source§impl Display for Type
Provides human-readable string formatting for types.
impl Display for Type
Provides human-readable string formatting for types.
Function types display optional parameters with a ? suffix. For example,
a function with signature (boolean, number?) -> string accepts 1 or 2 arguments.
Aggregate functions use => instead of -> in their signature.
§Examples
use eventql_parser::prelude::{Type, FunArgs};
// Basic types
assert_eq!(Type::Number.to_string(), "number");
assert_eq!(Type::String.to_string(), "string");
assert_eq!(Type::Bool.to_string(), "boolean");
// Array type
let arr = Type::Array(Box::new(Type::Number));
assert_eq!(arr.to_string(), "[]number");
// Function with all required parameters
let func = Type::App {
args: vec![Type::Number, Type::String].into(),
result: Box::new(Type::Bool),
aggregate: false,
};
assert_eq!(func.to_string(), "(number, string) -> boolean");
// Function with optional parameters
let func_optional = Type::App {
args: FunArgs {
values: vec![Type::Bool, Type::Number],
needed: 1,
},
result: Box::new(Type::String),
aggregate: false,
};
assert_eq!(func_optional.to_string(), "(boolean, number?) -> string");
// Aggregate function
let agg = Type::App {
args: vec![Type::Number].into(),
result: Box::new(Type::Number),
aggregate: true,
};
assert_eq!(agg.to_string(), "(number) => number");