-
Notifications
You must be signed in to change notification settings - Fork 22
Literals (OLAP)
[Table of Contents](https://github.com/dell-oss/Doradus/wiki/OLAP Databases: Table-of-Contents) | Previous | Next
Doradus Query Language: Literals
Most clauses contain a comparison that include a literal. When the comparison uses a predefined field whose type is known, the literal _should_ use a format compatible with that type. However, Doradus does not strictly enforce this. For example, if `Size` is declared as an integer, the following clause is allowed:
Size=Foo
Of course, because Size
is declared as an integer, it cannot match the value Foo
, so no objects will be selected by the clause.
The types of literals supported by Doradus are described below.
A Boolean literal is the keyword true
or false
(case-insensitive).
Doradus supports both integer and floating-point numeric literals. An integer literal is all digits, preceded with a minus sign (-) for negative values. Integer literals are considered long (64-bit). Floating-point constants use the same format supported by Java: an optional preceding sign, at least one digit, an optional fractional part, and an optional exponent, which may be signed. Example floating-point literals are shown below:
0
-123
3.14
10E12
2.718e-6
Timestamp literals have the general form:
"YYYY-MM-DD hh:mm:ss.fff"
Notes:
- In DQL expressions, timestamp values should be enclosed in single or double quotes.
- All time and date elements except for the year can be omitted from right-to-left if the preceding separator character ('.', ':', or '-') is also eliminated.
- When a timestamp value consists of a year only, the enclosing quotes can be omitted.
- Omitted time components default to 0; omitted date components default to 1.
Text fields can be evaluated as a set of tokens called terms. Depending on the underlying storage service, the terms may be generated and indexed when a text field is stored, or they may be computed dynamically. Generally, terms are alphanumeric character sequences separated by whitespace and/or punctuation.
In search clauses, multiple terms can be used, and each term can contain wildcards. Example search terms are shown below:
John
Fo*
a?c
Event_413
Note that terms are not quoted. A term is a sequence of characters consisting of letters, digits, or any of these characters:
? (question mark)
* (asterisk)
_ (underscore)
@ (at symbol)
# (hash or pound)
- (dash or minus)
In a term, the characters _
, @
, #
, and -
are treated as term separators, creating multiple terms that are part of the same literal. For example, the following literals all define two terms, john
and smith
– the separator character is not part of either term:
john_smith
john@smith
john#smith
john-smith
The characters ?
and *
are single- and multi-character wildcards: ?
matches any single character and *
matches any sequence of characters.
See the discussion on Text Contains Clauses for more details about using terms in searches.
Some clauses compare to a full text string instead of a term. When the text string conforms to the syntax of a term, it can be provided unquoted. Example:
Name=Smith
The value Smith
is a string because "=" follows the field name; if the field name was followed by ":", Smith would be treated as a term. See Equality Clauses described later.
When the string consists of multiple terms or contains characters not allowed in terms, the string must be enclosed in single or double quotes. Example:
Name="John Smith"
Note that to Doradus, object IDs are also strings. Therefore, when used in DQL queries, object ID literals may be provided as a single unquoted term or as a quoted string. Examples:
_ID=ISBN1234
Sender='cihSptpZrCM6oXaVQH6dwA=='
In a string, the characters ?
and *
are treated as wildcards as they are in terms. If a string needs a ?
or *
that must be used literally, they must be escaped. Escaping can also be used for non-printable or other characters. Doradus uses the backslash for escaping, and there are two escape formats:
-
\x
: Wherex
can be one of these characters:t
(tab character),b
(backspace),n
(newline or LF),r
(carriage return),f
(form feed),'
(single quote),"
(double quote), or\
(backslash). -
\uNNNN
: This escape sequence can be used for any Unicode character.NNNN
must consist of four hex characters 0-F.
For example, the string "Hello!World"
can also be specified as "Hello\u0021World"
.
Technical Documentation
[Doradus OLAP Databases](https://github.com/dell-oss/Doradus/wiki/Doradus OLAP Databases)
- Architecture
- OLAP Database Overview
- OLAP Data Model
- Doradus Query Language (DQL)
- OLAP Object Queries
- OLAP Aggregate Queries
- OLAP REST Commands
- Architecture
- Spider Database Overview
- Spider Data Model
- Doradus Query Language (DQL)
- Spider Object Queries
- Spider Aggregate Queries
- Spider REST Commands
- [Installing and Running Doradus](https://github.com/dell-oss/Doradus/wiki/Installing and Running Doradus)
- [Deployment Guidelines](https://github.com/dell-oss/Doradus/wiki/Deployment Guidelines)
- [Doradus Configuration and Operation](https://github.com/dell-oss/Doradus/wiki/Doradus Configuration and Operation)
- [Cassandra Configuration and Operation](https://github.com/dell-oss/Doradus/wiki/Cassandra Configuration and Operation)