All questions

Is there a technical syntax for CQL or only the English-like style?

Asked by clemd on

Cclemd

Every CQL example I find looks like user's score is greater than 90. Reading that in a code review diff is painful, apostrophes and prose where I expect operators. Is the English style the only option, or is there a normal syntax with comparison operators? Also curious whether variables exist or if every value has to be inlined into the expression.

Was this helpful?

2 answers

CEChibueze Eze

There are three interchangeable styles: natural, technical, and mixed. Your example in technical form is just

user.score > 90

and you can mix freely within one query, so a natural condition from a marketer and your operator-style additions coexist fine.

Variables exist too:

let rocket = "x", speed = 28000;

and & concatenates strings. Comments work with //, #, or /* */, which helps a lot in longer audience definitions that someone else has to maintain.

One detail to remember: keywords are case-insensitive but string literals are not, so the style you pick has no effect on matching, only readability.

Was this helpful?
Hhannah.j

We standardized on technical style for anything that lives in the repo and natural style for audiences the marketing team edits in the dashboard. Same language, evaluated the same way (the engine targets under 20ms per evaluation), so it is purely a convention question. Diffs got a lot more reviewable after we switched, so I sympathize with the apostrophe fatigue.

Was this helpful?
Still have questions?