pub struct Query<A> {
pub attrs: Attrs,
pub sources: Vec<Source<A>>,
pub predicate: Option<ExprRef>,
pub group_by: Option<GroupBy>,
pub order_by: Option<OrderBy>,
pub limit: Option<Limit>,
pub projection: ExprRef,
pub distinct: bool,
pub meta: A,
}Expand description
A complete EventQL query.
This is the root node of the AST, representing a full query with all its clauses. A query must have at least one source and a projection; other clauses are optional.
§Structure
FROM <alias> <source>
[FROM <alias> <source>] ...
[WHERE <condition>]
[GROUP BY <field> [HAVING <condition>]]
[ORDER BY <field> ASC|DESC]
[TOP|SKIP <n>]
PROJECT INTO [DISTINCT] <projection>§Examples
use eventql_parser::Session;
let mut session = Session::builder().use_stdlib().build();
let query = session.parse(
"FROM e IN events \
WHERE e.price > 100 \
ORDER BY e.timestamp DESC \
TOP 10 \
PROJECT INTO {id: e.id, price: e.price}"
).unwrap();
assert_eq!(query.sources.len(), 1);
assert!(query.predicate.is_some());
assert!(query.order_by.is_some());
assert!(query.limit.is_some());Fields§
§attrs: AttrsMetadata about this query
sources: Vec<Source<A>>FROM clause sources (must have at least one)
predicate: Option<ExprRef>Optional WHERE clause filter predicate
group_by: Option<GroupBy>Optional GROUP BY clause expression
order_by: Option<OrderBy>Optional ORDER BY clause
limit: Option<Limit>Optional LIMIT clause (TOP or SKIP)
projection: ExprRefPROJECT INTO clause expression (required)
distinct: boolRemove duplicate rows from the query’s results
meta: AType-level metadata about the query’s analysis state.
This field uses a generic type parameter to track whether the query is in a raw (unparsed/untyped) state or has been statically analyzed:
Query<Raw>: Query parsed but not yet type-checkedQuery<Typed>: Query that has passed static analysis with validated types and variable scopes
This provides compile-time guarantees about the query’s type safety.
Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for Query<A>where
A: Freeze,
impl<A> RefUnwindSafe for Query<A>where
A: RefUnwindSafe,
impl<A> Send for Query<A>where
A: Send,
impl<A> Sync for Query<A>where
A: Sync,
impl<A> Unpin for Query<A>where
A: Unpin,
impl<A> UnwindSafe for Query<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more