CaosDB Query Language Syntax

This is the documentation of the CaosDB Query Language Syntax. The authoritative specification of the syntax is the ANTLR4 grammar you can find in the source code: CQLParser.g4 and CQLLexer.g4

See examples in Query Language.

parser grammar CQLParser
rule cq

This is the root of the CQL grammar.

SELECTprop_selFROMFINDCOUNTversionroleentity_filterentityWHITE_SPACEentity_filterEOF

rule version

For versioned queries.

ANY_VERSION_OF

rule prop_sel

The comma-separated list of selected (sub)properties of a SELECT query.

prop_subselSELECT_COMMA

rule prop_subsel

The (sub-)selections (e.g. geolocation.longitude) of a SELECT query.

selector_txtSELECT_DOTprop_subsel

rule selector_txt

Rule for the allowed characters of a prop_subsel.

SELECT_DOUBLE_QUOTESELECT_DOUBLE_QUOTE_TXTSELECT_DOUBLE_QUOTE_ESCAPEDSELECT_DOUBLE_QUOTE_ENDSELECT_SINGLE_QUOTESELECT_SINGLE_QUOTE_TXTSELECT_SINGLE_QUOTE_ESCAPEDSELECT_SINGLE_QUOTE_ENDSELECTOR_TXTSELECT_ESCAPED

rule role

The entity role.

RECORDTYPERECORDPROPERTYFILEQUERYTEMPLATEENTITY

rule entity_filter

The filters of a FIND, SELECT, or COUNT query.

which_expLPARENWHITE_SPACEHAS_APROPERTYfilter_expressionconjunctiondisjunctionRPARENfilter_expressionconjunctiondisjunction

rule which_exp

WHICH keyword and syntactic sugar.

WHICHHAS_APROPERTYHAS_APROPERTYWITH_APROPERTYWHEREDOTWHITE_SPACE

rule filter_expression

Collection of different filters.

backreferencesubpropertyidfilterstoredattransactionpovsubpropertysubpropertynegation

rule idfilter

ID Filter (e.g. id > 10123).

minmaxIDOPERATORWHITE_SPACEvalue

rule transaction

Transaction filter (e.g INSERTED BY ME).

INSERTEDCREATEDUPDATEDtransactortransaction_timetransaction_timetransactor

rule transactor

The transactor (e.g. “user1”, or “ME”).

BYSOMEONEELSEBUTMESOMEONEELSEBUTentitySOMEONEELSEBUTusernameSOMEONEELSEMEentityusername

rule username

A user name or a user name pattern.

STAR~(STAR | WHITE_SPACE)

rule transaction_time

Time or timeframe of a transaction (for the transaction filter).

ATONINBEFOREUNTILAFTERSINCETODAYvalue

rule datetime

A date time or a fragment of a date time.

Not fully compliant with iso 8601 (TODO).

UNSIGNED_INTHYPHENUNSIGNED_INTHYPHENUNSIGNED_INTTXTUNSIGNED_INTCOLONUNSIGNED_INTCOLONUNSIGNED_INTDOTUNSIGNED_INT

rule pov

The property-operator-value filter (e.g. temperator > 240°C) and (optionally) subfilters.

propertyLIKElike_patternvalueOPERATORWHITE_SPACEvalueIS_NULLIS_NOT_NULLINvalueNEGATIONINvalueLIKElike_patternvalueOPERATORWHITE_SPACEvalueAS_ApropertyWHITE_SPACE

rule subproperty

Wrapper for a filter on referenced entities.

subproperty_filter

rule subproperty_filter

The actual filter on referenced entities.

which_expLPARENWHITE_SPACEfilter_expressionconjunctiondisjunctionRPARENfilter_expression

rule backreference

The backreference filter (e.g. REFERENCED BY …).

IS_REFERENCEDBYAentityWHITE_SPACEAS_ApropertyWHITE_SPACE

rule storedat

Stored-at filter for the path of files.

IS_STORED_ATlocationWHITE_SPACE

rule conjunction

Combine other filters with a logical AND.

filter_expressionLPARENWHITE_SPACEHAS_APROPERTYfilter_expressiondisjunctionconjunctionRPARENWHITE_SPACEANDwhich_expAPROPERTYfilter_expressionLPARENWHITE_SPACEfilter_expressiondisjunctionconjunctionRPAREN

rule disjunction

Combine other filter with a logical OR.

filter_expressionLPARENWHITE_SPACEHAS_APROPERTYfilter_expressionconjunctiondisjunctionRPARENORwhich_expAPROPERTYfilter_expressionLPARENWHITE_SPACEfilter_expressionconjunctiondisjunctionRPAREN

rule negation

Negation of another filter.

NEGATIONfilter_expressionLPARENWHITE_SPACEfilter_expressiondisjunctionconjunctionRPAREN

rule entity

An entity’s full name, id, or a pattern for a name.

regexp_patternlike_patterndouble_quotedsingle_quotedENTITY~(ENTITY | WHITE_SPACE | DOT)

rule regexp_pattern

A regexp pattern.

REGEXP_BEGINESC_REGEXP_END.REGEXP_END

rule like_pattern

A like pattern (e.g. “*oxide”).

~(WHITE_SPACE | DOT | LIKE | OPERATOR | AS_A | AND | OR | IS_STORED_AT | IS_REFERENCED)STAR~(WHITE_SPACE | DOT | STAR)

rule property

A Property’s name, id or a pattern of a name.

minmaxregexp_patternlike_patterndouble_quotedsingle_quotedTXTUNSIGNED_INTUNSIGNED_DECIMAL_NUMBERREGEXP_MARKERENTITYWHITE_SPACE

rule minmax

Expression for minumum or maximum.

THEGREATESTSMALLEST

rule value

A property value.

number_with_unitdatetimeatomWHITE_SPACE

rule number_with_unit

A number with a unit (e.g. 20m).

UNSIGNED_INTDECIMAL_NUMBERHYPHENPLUSWHITE_SPACEUNSIGNED_INTWHITE_SPACEunit

rule unit

A unit from a physical system of units or any other kind of system.

~(WHITE_SPACE | WHICH | HAS_A | WITH_A | WHERE | DOT | AND | OR | RPAREN)~WHITE_SPACEUNSIGNED_INTSLASH~WHITE_SPACE

rule location

A files path.

atom~WHITE_SPACE

rule atom

An atomic string or pattern.

double_quotedsingle_quoted~(WHITE_SPACE | DOT | RPAREN | LPAREN)

rule single_quoted

A single-quoted string or pattern.

SINGLE_QUOTE_STARTSINGLE_QUOTE_ESCAPED_CHARSINGLE_QUOTE_STAR~SINGLE_QUOTE_ENDSINGLE_QUOTE_END

rule double_quoted

A double-quoted string or pattern.

DOUBLE_QUOTE_STARTDOUBLE_QUOTE_ESCAPED_CHARDOUBLE_QUOTE_STAR~DOUBLE_QUOTE_ENDDOUBLE_QUOTE_END