4.3. Data Types and Operators in xGT

4.3.1. Data Types

The following data types are supported in xGT. Each column of the schema of a frame must be one of these data types.

4.3.1.1. BOOLEAN

The BOOLEAN type supports the storage of two values: true or false. Use the case insensitive keywords TRUE or FALSE or the integer values 1 or 0 to assign a BOOLEAN.

4.3.1.2. INTEGER

The INTEGER type holds signed numeric values. It stores any value between the range of -263 and 263 - 1. Attempting to assign values outside this range causes an error.

4.3.1.3. FLOAT

The FLOAT type holds single-precision (32-bit) floating-point values. Inputs with precision greater than 32 bits are valid input but will be truncated. The case-insensitive string NaN is also an acceptable value. Any other non decimal characters will result in an error.

4.3.1.4. DATE

The DATE type holds a date composed of a day, month, and year. The expected format for a DATE is YYYY-MM-DD where leading zeros must be given. For example, a valid DATE would be 2018-02-20. Assigning a DATE property with a valid DATETIME as described in the DATETIME section will result in the DATETIME being downcast and ignoring the time fields. Attempting to assign any other type will result in an error.

4.3.1.5. TIME

The TIME type holds a time composed of hours, minutes, seconds, and (optionally) a decimal fraction of a second. The expected format for a TIME is HH:MM:SS where leading zeros must be given. For example, a valid TIME would be 06:10:50. Optionally, a decimal fraction of a second can be included where the expected format is HH:MM:SS.S. This decimal must be 1 or more digits, but no more than 6 digits. For example, a valid TIME with a decimal fraction would be 06:10:50.0206. Attempting to assign any other type will result in an error.

In addition, a time zone can be indicated, though this will be converted to a Coordinated Universal Time (UTC) and the time zone will not be retained. Time zones are expressed either with a Z to indicated UTC or with an offset in containing an hour part and an optional minute part. The hour part must be between 14 and -14, and the minute part must be in 15 minute increments. The following formats are valid with or without a decimal fraction: HH:MM:SSZ, HH:MM:SS+HH:MM, HH:MM:SS-HH:MM, HH:MM:SS+HH, and HH:MM:SS-HH. For example, 06:10:50.0206+01:15 and 06:10:50-01:00 are valid times whereas 06:10:50+16 and 06:10:50+01:17 are not valid.

4.3.1.6. DATETIME

The DATETIME type holds a valid date and time separated by either a T or a space, where the date and time must be formatted as described above. It is composed of a day, month, year, hours, minutes, seconds, and optionally microseconds. The expected format for a DATETIME is YYYY-MM-DDTHH:MM:SS, YYYY-MM-DD HH:MM:SS, YYYY-MM-DDTHH:MM:SS.S, YYYY-MM-DD HH:MM:SS.S, YYYY-MM-DDTHH:MM:SSZ (UTC), YYYY-MM-DDTHH:MM:SS+HH:MM, YYYY-MM-DDTHH:MM:SS+HH, YYYY-MM-DDTHH:MM:SS-HH:MM, or YYYY-MM-DDTHH:MM:SS-HH. For example, a valid DATETIME would be 2018-12-20T06:10:50, 2018-12-20 06:10:50.02006, or 2018-12-20T06:10:50.02006+01:15. Assigning a DATE to a DATETIME will result in the DATE being “promoted” to a DATETIME with zeros for the time fields. Attempting to assign any other type will result in an error.

4.3.1.7. IPADDRESS

The IPADDRESS type holds an IPv4 address. The expected format of an IPADDRESS is XXX.XXX.XXX.XXX where each dot-separated value is between 0 and 255. For example, a valid IPADDRESS would be 172.16.254.1. Assigning any other type (including IPv6 addresses) will result in an error.

For situations where there are both IPv4 and IPv6 addresses in a single data source, it is recommended that the schema provide a TEXT type for that data.

4.3.1.8. TEXT

The TEXT type holds a string of UTF-8 encoded unicode characters.

4.3.2. Supported Operators

“Numeric” below refers to INTEGER and FLOAT data types. “Any” refers to any of the data types described above.

Operator

Operand 1

Operand 2

Result

Description

NOT

BOOLEAN

N/A

BOOLEAN

Boolean negation operator.

AND

BOOLEAN

BOOLEAN

BOOLEAN

Boolean conjunction operator.

OR

BOOLEAN

BOOLEAN

BOOLEAN

Boolean disjunction operator.

IS NULL / IS NOT NULL

Any

N/A

BOOLEAN

Null check.

=

Any

Any (of the same type as operand 1)

BOOLEAN

Equality comparison.

<>

Any

Any

BOOLEAN

Inequality comparison.

<, <=

Any

Any (of the same type as operand 1)

BOOLEAN

Less-than, less-than equal comparison.

<, <=

Numeric

Numeric

BOOLEAN

Numerical less-than, less-than equal comparison (type promotion is done for numeric types).

>, >=

Any

Any (of the same type as operand 1)

BOOLEAN

Greater-than, greater-than equal comparison.

>, >=

Numeric

Numeric

BOOLEAN

Numerical greater-than, greater-than equal comparison (type promotion is done for numeric types).

Additionally, the IN operator is supported for any data type. It is an n-ary operator with the left hand side being of any type and the right hand side being a list of literals (constants) of the same type:

a.name IN ["John", "Mary"]
b.id IN [1, 2, 3]
c.startdate IN [date("2000-01-01"), date("2002-01-01")]

The following arithmetic operators are supported with type promotion from integer to floating-point occurring automatically.

Operator

Operand 1

Operand 2

Result

Description

+

Numeric

Numeric

Numeric

Addition operator.

-

Numeric

Numeric

Numeric

Subtraction operator.

*

Numeric

Numeric

Numeric

Multiplication operator.

/

Numeric

Numeric

Numeric

Division operator.

%

Integer

Integer

Integer

Modulus (remainder) operator.

The following string operators are supported.

Operator

Operand 1

Operand 2

Result

Description

STARTS WITH

String

String

Boolean

True if the right-hand is a prefix of the left-hand side.

ENDS WITH

String

String

Boolean

True if the right-hand is a suffix of the left-hand side.

CONTAINS

String

String

Boolean

True if the right-hand is a substring of the left-hand side.

+

String

String

String

String concatenation.