Package com.sap.cds.ql
Interface CQL
public interface CQL
-
Field Summary
Modifier and TypeFieldDescriptionstatic final BooleanValue
static final NullValue
static final BooleanValue
-
Method Summary
Modifier and TypeMethodDescriptionstatic Predicate
and
(CqnPredicate p1, CqnPredicate p2) Creates a conjunction of two given predicatesstatic Predicate
and
(Iterable<? extends CqnPredicate> predicates) Creates a conjunction of given predicatesCreates an average function call on the given element or expression.static Predicate
Creates abetween
predicate that tests if thisvalue
is within a closed interval with given boundsstatic BooleanFunction
booleanFunc
(String name, List<? extends CqnValue> args) Creates a CDS QL function call that is send to the underlying data store.static Predicate
comparison
(CqnValue lhs, CqnComparisonPredicate.Operator op, CqnValue rhs) Creates a comparison predicate.static Predicate
connect
(CqnConnectivePredicate.Operator operator, Iterable<? extends CqnPredicate> predicates) Creates a logical connection of given predicatesCqnPredicate
.static <T> Literal<T>
constant
(T value) static Predicate
containment
(CqnContainmentTest.Position position, CqnValue value, CqnValue substring, boolean caseInsensitive) Creates a predicate that tests whether a string value contains a given substring at a given positionCqnContainmentTest.Position
static Predicate
Creates a predicate that tests whether a string value contains a given substringstatic RefBuilder<ElementRef<?>>
copy
(CqnElementRef ref) Creates aRefBuilder
from the given ref, which allows for in-place modification of the ref.static Expand<?>
Creates a copy of the given expand.static Predicate
copy
(CqnPredicate pred) Creates a copy of the given predicate.static Predicate
copy
(CqnPredicate pred, Modifier modifier) Creates a modified copy of the given predicate.static RefBuilder<StructuredTypeRef>
copy
(CqnStructuredTypeRef ref) Creates aRefBuilder
from the given ref, which allows for in-place modification of the ref.static <S extends CqnStatement>
Scopy
(S statement) Creates a copy of the given CQN statement.static <S extends CqnStatement>
SCreates a modified copy of the given CQN statement.cosineSimilarity
(CqnValue vector1, CqnValue vector2) Creates a CDS QL function to compute the cosine similarity of two vectors.count()
Creates a count all function call.count
(CqnElementRef element) Creates a count function call on the given element.countDistinct
(CqnValue value) Creates an count distinct function call on the given element or expression.static Predicate
Creates a predicate that tests whether a string value ends with a given suffixstatic <T extends StructuredType<T>>
TCreates aStructuredType
representing a CDS entity.static StructuredType<?>
Creates aStructuredType
representing a CDS entity.static Predicate
eTag
(CqnElementRef elementRef, Object value) Creates aCqnEtagPredicate
predicate.static Predicate
eTag
(CqnListValue values) Creates aCqnEtagPredicate
predicate.static Predicate
Creates aCqnEtagPredicate
predicate.static Predicate
Creates an exists predicate that tests if a given subquery returns any rowexpression
(CqnValue left, CqnArithmeticExpression.Operator op, CqnValue right) Creates an arithmetic expression.static <T> FunctionCall<T>
Creates a CDS QL function call that is send to the underlying data store.static <T> FunctionCall<T>
Creates a CDS QL function call that is send to the underlying data store.static <T> ElementRef<T>
Creates anElementRef
representing a path from a CDS entity to an element of this or another entity.static <T> ElementRef<T>
get
(List<? extends CqnReference.Segment> segments) Creates anElementRef
representing a path from a CDS entity to an element of this or another entity.static Predicate
Creates anin
predicate.static Predicate
in
(CqnValue value, Collection<? extends CqnValue> values) Creates anin
predicate.static Predicate
Creates a predicate that checks if the values of the given elements match any of the given value sets.l2Distance
(CqnValue vector1, CqnValue vector2) Creates a CDS QL function to compute the L2 distance of two vectors.static CqnListValue
Creates aCqnListValue
composing given valuesstatic CqnListValue
Creates aCqnListValue
composing given valuesstatic Predicate
match
(CqnStructuredTypeRef ref, CqnPredicate pred, CqnMatchPredicate.Quantifier quantifier) Creates a match predicate that tests if a given ref matches a given filterstatic Predicate
matchesPattern
(CqnValue value, CqnValue pattern) Creates a predicate that tests if this value matches a specified regular expressionstatic Predicate
matchesPattern
(CqnValue value, CqnValue pattern, boolean caseInsensitive, boolean multiLineSensitive) Creates a predicate that tests if this value matches a specified regular expressionstatic Predicate
matchesPattern
(CqnValue value, CqnValue pattern, CqnValue options) Creates a predicate that tests if this value matches a specified regular expressionstatic Predicate
matchesPattern
(CqnValue value, String pattern) Creates a predicate that tests if this value matches a specified regular expressionstatic Predicate
Creates a predicate from a map of element names to values or parameters.static <T> Value<T>
Creates a max function call on the given element or expression.static <T> Value<T>
Creates a min function call on the given element or expression.static Predicate
not
(CqnPredicate predicate) Negates a givenCqnPredicate
.now()
Creates anElementRef
to be used in queries to represent $now.static Predicate
or
(CqnPredicate p1, CqnPredicate p2) Creates a disjunction of two given predicatesstatic Predicate
or
(Iterable<? extends CqnPredicate> predicates) Creates a disjunction of given predicatesstatic <T> Parameter<T>
param
(int index) Creates an indexedParameter
to be used in CQN statements.static <T> Parameter<T>
Creates a namedParameter
to be used in queries.static Value<?>
Creates a CQN plain value, which is directly send to the underlying data store.static CqnReference.Segment
refSegment
(String id) Creates a segment of a structured type or element reference without filter.static CqnReference.Segment
refSegment
(String id, CqnPredicate filter) Creates a segment of a structured type or element reference with a filter condition.static List<CqnReference.Segment>
refSegments
(List<String> segmentIds) Creates a list of reference segments without filter.static Predicate
Creates a search predicate.static CqnSortSpecification
sort
(CqnValue value, CqnSortSpecification.Order order) Creates aCqnSortSpecification
that sorts a value by a given orderstatic CqnStar
star()
static Predicate
startsWith
(CqnValue value, CqnValue prefix, boolean caseInsensitive) Creates a predicate that tests whether a string value starts with a given prefixCreates a sum function call on the given element or expression.static StructuredType<?>
Creates aStructuredType
representing a path from a CDS entity to another entity.static StructuredType<?>
to
(List<? extends CqnReference.Segment> segments) Creates aStructuredType
representing a path from a CDS entity to another entity.Creates a CDS QL expression for converting the given string value to lower case using the rules of the underlying data store.Creates a CDS QL expression for converting the given string value to lower case using the rules of the underlying data store.Creates a CDS QL expression for converting the given string value to upper case using the rules of the underlying data store.Creates a CDS QL expression for converting the given string value to upper case using the rules of the underlying data store.userId()
Creates anElementRef
on the available $user.id value.Creates anElementRef
on the available $user.locale value.static <T> Literal<T>
val
(T value) Creates anElementRef
on the available $validFrom value.validTo()
Creates anElementRef
on the available $validTo value.static CqnVector
Creates a newCqnVector
which can be used in vector functions such ascosineSimilarity(com.sap.cds.ql.cqn.CqnValue, com.sap.cds.ql.cqn.CqnValue)
andl2Distance(com.sap.cds.ql.cqn.CqnValue, com.sap.cds.ql.cqn.CqnValue)
.static Collector<CqnPredicate,
?, CqnPredicate> withAnd()
Returns aCollector
that connects the input predicates with AND.static Collector<CqnPredicate,
?, CqnPredicate> withOr()
Returns aCollector
that connects the input predicates with OR.
-
Field Details
-
TRUE
-
FALSE
-
NULL
-
-
Method Details
-
copy
Creates aRefBuilder
from the given ref, which allows for in-place modification of the ref.- Parameters:
ref
- the ref to be copied- Returns:
- the ref builder
-
copy
Creates aRefBuilder
from the given ref, which allows for in-place modification of the ref.- Parameters:
ref
- the element ref to be copied- Returns:
- the ref builder
-
copy
Creates a copy of the given expand.- Parameters:
expand
- the expand to be copied- Returns:
- the copy
-
copy
Creates a copy of the given predicate.- Parameters:
pred
- the predicate to be copied- Returns:
- the copy
-
copy
Creates a modified copy of the given predicate.- Parameters:
pred
- the predicate to be copiedmodifier
- the modifier for altering the copy- Returns:
- the modified copy
-
copy
Creates a copy of the given CQN statement.- Type Parameters:
S
- the type of CqnStatement- Parameters:
statement
- the CQN statement to be copied- Returns:
- the copy
-
copy
Creates a modified copy of the given CQN statement.- Type Parameters:
S
- the type of CqnStatement- Parameters:
statement
- the CQN statement to be copiedmodifier
- the modifier for altering the copy- Returns:
- the modified copy
-
func
Creates a CDS QL function call that is send to the underlying data store.- Type Parameters:
T
- the return type of the function call- Parameters:
name
- the name of the function to be calledargs
- the arguments of the function- Returns:
- the CDS QL function call
-
func
Creates a CDS QL function call that is send to the underlying data store.- Type Parameters:
T
- the return type of the function call- Parameters:
name
- the name of the function to be calledargs
- the arguments of the function- Returns:
- the CDS QL function call
-
booleanFunc
Creates a CDS QL function call that is send to the underlying data store.- Parameters:
name
- the name of the function to be calledargs
- the arguments of the function- Returns:
- the CDS QL function call
-
constant
- Type Parameters:
T
- the type of the constant- Parameters:
value
- the value- Returns:
- the constant
-
val
- Type Parameters:
T
- the type of the non-constant value- Parameters:
value
- the value of the non-constant value- Returns:
- the value
- See Also:
-
vector
Creates a newCqnVector
which can be used in vector functions such ascosineSimilarity(com.sap.cds.ql.cqn.CqnValue, com.sap.cds.ql.cqn.CqnValue)
andl2Distance(com.sap.cds.ql.cqn.CqnValue, com.sap.cds.ql.cqn.CqnValue)
.- Parameters:
vector
- the vector as float[] or in String format- Returns:
- the
CqnVector
-
not
Negates a givenCqnPredicate
.- Parameters:
predicate
- theCqnPredicate
to be negated- Returns:
- the negated predicate
-
and
Creates a conjunction of two given predicates- Parameters:
p1
- 1st operand of the conjunctionp2
- 2nd operand of the conjunction- Returns:
- the conjunction
-
withAnd
Returns aCollector
that connects the input predicates with AND. If there are none theCollector
returns TRUE.- Returns:
- the collector
-
or
Creates a disjunction of two given predicates- Parameters:
p1
- 1st operand of the disjunctionp2
- 2nd operand of the disjunction- Returns:
- the disjunction
-
and
Creates a conjunction of given predicates- Parameters:
predicates
- the predicates to connect- Returns:
- the conjunction
-
or
Creates a disjunction of given predicates- Parameters:
predicates
- the predicates to connect- Returns:
- the disjunction
-
withOr
Returns aCollector
that connects the input predicates with OR. If there are none theCollector
returns FALSE.- Returns:
- the collector
-
connect
static Predicate connect(CqnConnectivePredicate.Operator operator, Iterable<? extends CqnPredicate> predicates) Creates a logical connection of given predicatesCqnPredicate
.- Parameters:
operator
- operator to connect the predicates withpredicates
- the predicates to connect- Returns:
- the logical connection
-
param
Creates an indexedParameter
to be used in CQN statements. Can be used with positional parameter values.- Type Parameters:
T
- the type of the parameter- Parameters:
index
- the parameter index. If used with positional parameter values, start with 0 for the first parameter- Returns:
- the parameter
-
param
Creates a namedParameter
to be used in queries.- Type Parameters:
T
- the type of the parameter- Parameters:
name
- the parameter name- Returns:
- the parameter
-
plain
Creates a CQN plain value, which is directly send to the underlying data store.- Parameters:
value
- the value content- Returns:
- the plain value
-
count
Creates a count all function call.- Returns:
- the count value
-
count
Creates a count function call on the given element.- Parameters:
element
- the ref to the element to be counted- Returns:
- the count value
-
min
Creates a min function call on the given element or expression.- Type Parameters:
T
- the type of the value- Parameters:
value
- the ref to the element to be counted or an expression- Returns:
- the minimum value
-
max
Creates a max function call on the given element or expression.- Type Parameters:
T
- the type of the value- Parameters:
value
- the ref to the element to be counted or an expression- Returns:
- the maximum value
-
sum
Creates a sum function call on the given element or expression.- Parameters:
value
- the ref to the element to be counted or an expression- Returns:
- the sum value
-
average
Creates an average function call on the given element or expression.- Parameters:
value
- the ref to the element to be counted or an expression- Returns:
- the average value
-
countDistinct
Creates an count distinct function call on the given element or expression.- Parameters:
value
- the ref to the element to be counted or an expression- Returns:
- the count of distinct values
-
contains
Creates a predicate that tests whether a string value contains a given substring- Parameters:
value
- the string valuesubstring
- the substring to test forcaseInsensitive
- whether the test should be case insensitive- Returns:
- the predicate for the containment test
-
startsWith
Creates a predicate that tests whether a string value starts with a given prefix- Parameters:
value
- the string valueprefix
- the prefix to test forcaseInsensitive
- whether the test should be case insensitive- Returns:
- the predicate for the containment test
-
endsWith
Creates a predicate that tests whether a string value ends with a given suffix- Parameters:
value
- the string valuesuffix
- the suffix to test forcaseInsensitive
- whether the test should be case insensitive- Returns:
- the predicate for the containment test
-
containment
static Predicate containment(CqnContainmentTest.Position position, CqnValue value, CqnValue substring, boolean caseInsensitive) Creates a predicate that tests whether a string value contains a given substring at a given positionCqnContainmentTest.Position
- Parameters:
position
- the positionvalue
- the string valuesubstring
- the substring to test forcaseInsensitive
- whether the test should be case insensitive- Returns:
- the predicate for the containment test
-
toLower
Creates a CDS QL expression for converting the given string value to lower case using the rules of the underlying data store.- Parameters:
val
- the String value to be converted- Returns:
- the CDS QL expression for lower case conversion
-
toLower
Creates a CDS QL expression for converting the given string value to lower case using the rules of the underlying data store.- Parameters:
val
- the String value to be converted- Returns:
- the CDS QL expression for lower case conversion
-
toUpper
Creates a CDS QL expression for converting the given string value to upper case using the rules of the underlying data store.- Parameters:
val
- the String value to be converted- Returns:
- the CDS QL expression for upper case conversion
-
toUpper
Creates a CDS QL expression for converting the given string value to upper case using the rules of the underlying data store.- Parameters:
val
- the String value to be converted- Returns:
- the CDS QL expression for upper case conversion
-
cosineSimilarity
Creates a CDS QL function to compute the cosine similarity of two vectors.- Parameters:
vector1
- the first vectorvector2
- the second vector- Returns:
- the cosine similarity function
-
l2Distance
Creates a CDS QL function to compute the L2 distance of two vectors.- Parameters:
vector1
- the first vectorvector2
- the second vector- Returns:
- the L2 distance function
-
entity
Creates aStructuredType
representing a CDS entity.- Parameters:
qualifiedName
- the qualified name of the CDS entity- Returns:
- the
StructuredType
representing the CDS entity
-
entity
Creates aStructuredType
representing a CDS entity.- Type Parameters:
T
- the type of the entity- Parameters:
type
- the class of the entity type- Returns:
- the
StructuredType
representing the CDS entity
-
to
Creates aStructuredType
representing a path from a CDS entity to another entity.- Parameters:
path
- a String of association element names separated by '.'- Returns:
- the
StructuredType
representing the path to a CDS entity
-
to
Creates aStructuredType
representing a path from a CDS entity to another entity. To create aStructuredTypeRef
, useCQL.to(segments).asRef()
.- Parameters:
segments
- the segments of the path- Returns:
- the
StructuredType
representing the path to a CDS entity
-
get
Creates anElementRef
representing a path from a CDS entity to an element of this or another entity.- Type Parameters:
T
- the type of the element- Parameters:
path
- a String of element names separated by '.', where all except the last segment represent association elements.- Returns:
- the
ElementRef
representing the path to the CDS element
-
get
Creates anElementRef
representing a path from a CDS entity to an element of this or another entity.- Type Parameters:
T
- the type of the element- Parameters:
segments
- the segments of the path- Returns:
- the
ElementRef
representing the path to the CDS element
-
refSegment
Creates a segment of a structured type or element reference without filter. UserefSegment(String, CqnPredicate)
to create a segment with filter condition.- Parameters:
id
- the id of the segment- Returns:
- the segment
-
refSegment
Creates a segment of a structured type or element reference with a filter condition.- Parameters:
id
- the id of the segmentfilter
- the filter of the segment- Returns:
- the segment
-
refSegments
Creates a list of reference segments without filter.- Parameters:
segmentIds
- the ids of the segments- Returns:
- the segments
-
expression
Creates an arithmetic expression.- Parameters:
left
- the left-hand side of the expressionop
- the operatorright
- the right-hand side of the expression- Returns:
- the arithmetic expression
-
comparison
Creates a comparison predicate.- Parameters:
lhs
- the left-hand side of the comparisonop
- the comparison operatorrhs
- the right-hand side of the comparison- Returns:
- the comparison predicate
-
in
Creates anin
predicate.- Parameters:
value
- the value to be checked if it's contained in the collectionvalues
- the collection of values- Returns:
- the
in
predicate
-
between
Creates abetween
predicate that tests if thisvalue
is within a closed interval with given bounds- Parameters:
value
- the value to be checked if it's contained in a closed interval betweenlow
andhigh
low
- the lower boundhigh
- the upper bound- Returns:
- the
between
predicate
-
in
Creates anin
predicate.- Parameters:
value
- the value to be checked if it's contained in the collectionvalueSet
- the value describing a collection of values- Returns:
- the
in
predicate
-
in
Creates a predicate that checks if the values of the given elements match any of the given value sets. The value sets to test against are computed from the given value maps by extracting the values for the given elements.- Parameters:
elements
- the element namesvalueMaps
- the value maps to match against
-
eTag
Creates aCqnEtagPredicate
predicate.- Parameters:
values
- the list of ETag values- Returns:
- the
eTag
predicate
-
eTag
Creates aCqnEtagPredicate
predicate.- Parameters:
value
- the ETag value- Returns:
- the
eTag
predicate
-
eTag
Creates aCqnEtagPredicate
predicate.- Parameters:
elementRef
- the reference to ETag elementvalue
- the ETag values- Returns:
- the
eTag
predicate
-
search
Creates a search predicate.- Parameters:
term
- the search term- Returns:
- the search predicate
-
exists
Creates an exists predicate that tests if a given subquery returns any row- Parameters:
subQuery
- the subquery that performs the existence test- Returns:
- the exists predicate
-
match
static Predicate match(CqnStructuredTypeRef ref, CqnPredicate pred, CqnMatchPredicate.Quantifier quantifier) Creates a match predicate that tests if a given ref matches a given filter- Parameters:
ref
- the referencepred
- the filterquantifier
- all or any- Returns:
- the match predicate
-
now
Creates anElementRef
to be used in queries to represent $now.- Returns:
- the now value
-
validFrom
Creates anElementRef
on the available $validFrom value.- Returns:
- the validFrom value
-
validTo
Creates anElementRef
on the available $validTo value.- Returns:
- the validTo value
-
userLocale
Creates anElementRef
on the available $user.locale value.- Returns:
- the locale string value
-
userId
Creates anElementRef
on the available $user.id value.- Returns:
- the user.id value
-
star
-
list
Creates aCqnListValue
composing given values- Parameters:
values
- the components- Returns:
- the list value
-
list
Creates aCqnListValue
composing given values- Parameters:
values
- the items- Returns:
- the list value
-
matching
Creates a predicate from a map of element names to values or parameters. The map entries are transformed into equality predicates and joined via and.- Parameters:
elementToValueMap
- the element name to value map defining the condition- Returns:
- the matching predicate
-
sort
Creates aCqnSortSpecification
that sorts a value by a given order- Parameters:
value
- the valueorder
- the order- Returns:
- the sort specification
-
matchesPattern
Creates a predicate that tests if this value matches a specified regular expression- Parameters:
value
- the value that is testedpattern
- Regular expression represented as a string valueoptions
- Regular expression options represented as a string value- Returns:
- the predicate to match the expression
-
matchesPattern
Creates a predicate that tests if this value matches a specified regular expression- Parameters:
value
- the value that is testedpattern
- Regular expression represented as a string value- Returns:
- the predicate to match the expression
-
matchesPattern
Creates a predicate that tests if this value matches a specified regular expression- Parameters:
value
- the value that is testedpattern
- Regular expression represented as a plain string- Returns:
- the predicate to match the expression
-
matchesPattern
static Predicate matchesPattern(CqnValue value, CqnValue pattern, boolean caseInsensitive, boolean multiLineSensitive) Creates a predicate that tests if this value matches a specified regular expression- Parameters:
value
- the value that is testedpattern
- Regular expression represented as a string valuecaseInsensitive
- If true, the test is case-insensitivemultiLineSensitive
- If true, the test is multi-line sensitive- Returns:
- the predicate to match the expression
-