Literal Constant
Each data type in Doris corresponds to a Literal of such type. The user can specify Literal in SQL statements, such as in the selected list, WHERE clauses, and function’s parameters.
Literal Constant of Numbers
The literal constant of integer types, such as TINYINT, SMALLINT, INT, and BIGINT, is a series of numbers that can be preceded by 0.
The literal constant of floatingpoint type, such as DOUBLE, is a series of numbers, optionally with a decimal dot, i.e., . character.
If required, the integer types can be promoted to floating-point type depending on the context.
When describing literal constants, exponential symbols, such as character e, can be used . For example, 1e+6 represents 10 to the sixth power, i.e., 1 million. Literal constants containing an exponent sign are recognized as floating point type.
Literal Constant of Strings
String literal constants are put in a single or double quotation marks. The literal constant of the string also includes the ones in other forms: the literal constant of the string is a string containing single quotation marks, which are enclosed within double quotation marks. The literal constant of a string is a string containing double quotation marks, which is put within single quotation marks.
To describe special characters of literal constant of a string, escape characters (\ character) need to be added before the special characters.
- \t means the tab key
- \n means the newline character
- \r means the enter character
- \b means the fallback character
- \0 means the null character of ASCII code, which is different from the NULL in SQL.
- \Z means the endoftext character in dos environment.
- \% and _ are used to escape wildcard characters in strings passed to the operator LIKE
- \\ prevents the backslash symbol from being interpreted as an escape character.
- If the literal constant of a string is enclosed in single or double quotation marks, the backslash can be used to escape the single or double quotation marks that appear in the literal constant of the string.
- If the character appearing after \ is not the escape characters listed above, the character should remain unchanged and should not be escaped.
Literal Constant of Date
Doris automatically converts CHAR type literal constants to DATE type literal constants. The time type literal constant accepted by Doris is in the input format of YYYYMMDD HH: MM: SS. ssssss, or contains the date only. The number (milliseconds) after decimal point in the above-mentioned format may be given or ignored. For example, the user can specify the time type as '2010-01-01', or '2010-01-01 10:10:10'.