openLooKeng has a set of built-in data types, described below. Additional types can be provided by plugins.
Connectors are not required to support all types. See Connectors for details on supported types.
This type captures boolean values
A 8-bit signed two's complement integer with a minimum value of
-2^7and a maximum value of
2^7 - 1.
A 16-bit signed two's complement integer with a minimum value of
-2^15and a maximum value of
2^15 - 1.
A 32-bit signed two's complement integer with a minimum value of
-2^31and a maximum value of
2^31 - 1. The name
INTis also available for this type.
A 64-bit signed two's complement integer with a minimum value of
-2^63and a maximum value of
2^63 - 1.
A real is a 32-bit inexact, variable-precision implementing the IEEE Standard 754 for Binary Floating-Point Arithmetic.
FLOATis also available for this type.
Example: REAL ‘10.3’, REAL ‘10.3e0’, REAL ‘1.03e1’
A double is a 64-bit inexact, variable-precision implementing the IEEE Standard 754 for Binary Floating-Point Arithmetic.
DOUBLE PRECISIONis also available for this type.
A fixed precision decimal number. Precision up to 38 digits is supported but performance is best up to 18 digits.
DECis also available for this type.
The decimal type takes two literal parameters:
- precision - total number of digits
- scale - number of digits in fractional part. Scale is optional and defaults to 0.
Example type definitions:
For compatibility reasons decimal literals without explicit type specifier (e.g.
1.2) are treated as the values of the
DOUBLEtype by default, but this is subject to change in future releases. This behavior is controlled by:
- System wide property:
- Session wide property:
Variable length character data with an optional maximum length.
STRINGis also available for this type. Please be advised,
STRINGdefined an unlimited length character data, you should not specify the length, otherwise it will be same as
Example type definitions:
SQL statements support simple literal, as well as Unicode usage:
- literal string :
'Hello winter !'
- Unicode string with default escape character:
U&'Hello winter \2603 !'
- Unicode string with custom escape character:
U&'Hello winter #2603 !' UESCAPE '#'
A Unicode string is prefixed with
U&and requires an escape character before any Unicode character usage with 4 digits. In the examples above
#2603represent a snowman character. Long Unicode codes with 6 digits require usage of the plus symbol before the code. For example, you need to use
\+01F600for a grinning face emoji.
Fixed length character data. A
CHARtype without length specified has a default length of 1. A
CHAR(x)value always has
xcharacters. For instance, casting
CHAR(7)adds 4 implicit trailing spaces. Leading and trailing spaces are included in comparisons of
CHARvalues. As a result, two character values with different lengths (
x != y) will never be equal.
Example type definitions:
Variable length binary data.
Binary strings with length are not yet supported:
JSON value type, which can be a JSON object, a JSON array, a JSON number, a JSON string,
Date and Time
Calendar date (year, month, day).
Time of day (hour, minute, second, millisecond) without a time zone. Values of this type are parsed and rendered in the session time zone.
TIME WITH TIME ZONE
Time of day (hour, minute, second, millisecond) with a time zone. Values of this type are rendered using the time zone from the value.
TIME '01:02:03.456 America/Los_Angeles'
Instant in time that includes the date and time of day without a time zone. Values of this type are parsed and rendered in the session time zone.
TIMESTAMP '2001-08-22 03:04:05.321'
TIMESTAMP WITH TIME ZONE
Instant in time that includes the date and time of day with a time zone. Values of this type are rendered using the time zone from the value.
TIMESTAMP '2001-08-22 03:04:05.321 America/Los_Angeles'
INTERVAL YEAR TO MONTH
Span of years and months.
INTERVAL '3' MONTH
INTERVAL DAY TO SECOND
Span of days, hours, minutes, seconds and milliseconds.
INTERVAL '2' DAY
An array of the given component type.
ARRAY[1, 2, 3]
A map between the given component types.
MAP(ARRAY['foo', 'bar'], ARRAY[1, 2])
A structure made up of fields that allows mixed types. The fields may be of any SQL type.
By default, row fields are not named, but names can be assigned.
CAST(ROW(1, 2.0) AS ROW(x BIGINT, y DOUBLE))
Named row fields are accessed with field reference operator
CAST(ROW(1, 2.0) AS ROW(x BIGINT, y DOUBLE)).x
Named or unnamed row fields are accessed by position with the subscript operator
. The position starts at
1and must be a constant.
An IP address that can represent either an IPv4 or IPv6 address. Internally, the type is a pure IPv6 address. Support for IPv4 is handled using the IPv4-mapped IPv6 address range (RFC 4291#section-220.127.116.11). When creating an
IPADDRESS, IPv4 addresses will be mapped into that range. When formatting an
IPADDRESS, any address within the mapped range will be formatted as an IPv4 address. Other addresses will be formatted as IPv6 using the canonical format defined in RFC 5952.
This type represents a UUID (Universally Unique IDentifier), also known as a GUID (Globally Unique IDentifier), using the format defined in RFC 4122.
A HyperLogLog sketch allows efficient computation of approx_distinct(). It starts as a sparse representation, switching to a dense representation when it becomes more efficient.
A P4HyperLogLog sketch is similar to
hyperloglog_type, but it starts (and remains) in the dense representation.
A quantile digest (qdigest) is a summary structure which captures the approximate distribution of data for a given input set, and can be queried to retrieve approximate quantile values from the distribution. The level of accuracy for a qdigest is tunable, allowing for more precise results at the expense of space.
A qdigest can be used to give approximate answer to queries asking for what value belongs at a certain quantile. A useful property of qdigests is that they are additive, meaning they can be merged together without losing precision.
A qdigest may be helpful whenever the partial results of
approx_percentilecan be reused. For example, one may be interested in a daily reading of the 99th percentile values that are read over the course of a week. Instead of calculating the past week of data with
qdigests could be stored daily, and quickly merged to retrieve the 99th percentile value.