Developers

Data types


Data types

PQL supports the following types in constants natively:

Integers

64-bit signed integers in the range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Integers can be specified in decimal (such as 10 or 234543), hexadecimal (such as 0xff00 or 0x00123) and octal (such as 07 or 01263).

Non-integer values can be type-cast to integers using the integer() function.

Floats

64-bit floating point number in the range 10e-308 to 10e308.

You can use floating point numbers in PQL to get fractional results, or display results with decimal places.

Non-floating point values can be type-cast to floats using the float() function.

Strings

Any sequence of characters surrounded a pair of single quotes, such as '10.10.23.45' or 'eth0'. Within a string, you can escape single quotes by repeating them, such as 'I don''t mind apostrophes'.

Non-string values can be type-cast to strings using the string() function.

Regular expressions

Any sequence of characters surrounded by a pair of question marks, such as ?10\.10\.\d+\.\d+? or ?c.*s?. PQL supports the syntax used by the PCRE library version 7.7. In PQL, you can use regular expressions in the predicate and as a function.

You can use regular expressions as a data type in a predicate (the WHERE clause), where it is useful for comparing a value with the regular expression to check for a match (see examples).

Use question marks to delimit regular expressions because in PQL, the forward slash is reserved for paths.

Timestamps

A timestamp represents either a point in time, or a duration in time. Times are measured with a resolution of 1 microsecond from the standard unix epoch of midnight, January 1, 1970. Timestamps can be specified as strings or integers, which must then be type-cast to a timestamp. Integers are the number of microseconds in the interval or since the epoch. Strings can refer to an exact time, such as '2007-07-27T18:16:21.0000000Z' or to a relative time in words, such as 'now', '1 hour ago', or as a duration, such as '2 days 4 hours 1 minute'.

Non-timestamp values can be type-cast to timestamps using the timestamp(), date(), or time() functions.

You must cast at least one operand to a timestamp before performing arithmetic on timestamps. Timestamps are measured in microseconds, so
timestamp('now') + 1000000 is the same as timestamp('now') + '1 second'. You can describe time using common strings such as '1 week ago' or '34 hours 4 seconds' or 3 minutes hence' and more. You can also specify a time exactly by using the format 'yyyy-mm-ddThh:mm:ss.uuuuuu' as in the example:
SELECT timestamp('now') from /.

PQL recognizes the following timestamp phrases:

  • now
  • 1 day ago
  • 2 days ago
  • 1 minute ago
  • 3 minutes
  • 4 weeks
  • 8 weeks hence (meaning 8 weeks from now)
  • 1 minute hence

How do I find out more?