Skip to content

Commit

Permalink
#2178 Enhance the grammar with rules for "order by" expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
homedirectory committed Feb 23, 2024
1 parent 84bc47d commit 8e0fc26
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class CanonicalEqlGrammar {
start(Query).

specialize(Query).
into(Select, StandaloneExpression, StandaloneCondExpr).
into(Select, StandaloneExpression, StandaloneCondExpr, OrderBy).

derive(Select).
to(select.with(Class.class),
Expand Down Expand Up @@ -277,13 +277,24 @@ public final class CanonicalEqlGrammar {
to(expr, label("operand", YieldOperand), repeat(ArithmeticalOperator, YieldOperand), model).

derive(StandaloneCondExpr).
to(cond, label("condition", StandaloneCondition), model).
to(cond, StandaloneCondition, model).

derive(StandaloneCondition).
to(Predicate).
or(label("left", StandaloneCondition), and, label("right", StandaloneCondition)).
or(label("left", StandaloneCondition), or, label("right", StandaloneCondition)).

derive(OrderBy).
to(orderBy, repeat1(OrderByOperand), model).

derive(OrderByOperand).
to(SingleOperandOrExpr, Order).
or(yield.with(STR), Order).
or(order.with(OrderingModel.class)).

derive(Order).
to(asc).or(desc).

build();
// @formatter:on

Expand All @@ -306,7 +317,7 @@ public enum EqlVariable implements Variable {
UnaryPredicate,
ComparisonPredicate, QuantifiedComparisonPredicate, LikePredicate, AliasedYield, YieldManyModel, Yield1Model, Yield1, YieldMany, StandaloneCondExpr,
StandaloneCondition,
MembershipPredicate
OrderBy, Order, OrderByOperand, MembershipPredicate
}

public enum EqlTerminal implements Terminal {
Expand Down Expand Up @@ -356,7 +367,7 @@ public enum EqlTerminal implements Terminal {
beginExpr, endExpr,
join, leftJoin, on,
yield, yieldAll,
groupBy, asc, desc, order, cond,
groupBy, asc, desc, order, cond, orderBy,
}

private CanonicalEqlGrammar() {}
Expand Down

0 comments on commit 8e0fc26

Please sign in to comment.