When modelling with CDS and its family of languages we have access to a wide selection of clean and concise declarative syntax. In the expressions area there are expressions (and in particular path expressions) and also a certain style of filter.
These filters can be used in various places and are a great example of how CDS models elevate us from underlying SQL, up to a domain model layer, where intent can be expressed more simply (and less technically).
Here's how this special filter is defined:
And here are some examples of how it's used (and thus also what it "looks like").
In an exists predicate:
SELECT from Authors { name }
where exists books[stock > 100]In a from clause:
SELECT from Books[price > 19.99]
{ author.name as name }There's a path expression in that example too, and talking of path expressions, it can be used between segments of a path in such path expressions:
SELECT from Books
{ title, author[age < 40].name as author }This type of filter has a name denoting where it appears. What is that name (the name is a single word, and let's agree to write it all in lower case)?
This is a question from the June Developer Challenge on CAP Knowledge. And don't forget: always submit your answer as a hash, on its own - read the Taking part section of the intro post for more info. At the end of today, this question will be updated with links to further reading on this topic.
Further info:
- The Infix Filters section of the CXL topic is a great resource for this subject, and there's also a small section in the CQL topic too.
- In the notes to Part 9 of The Art and Science of CAP, the section Projections, selections and infix notation digs in to infix filters a little more.
- In the notes to part 6 of the CDS expressions in CAP series, the section Combining the scoped syntax with infix filters also goes into some depth.