Preql Types¶
-
any
A meta-type that can match any type.
Subtypes: unknown, type, object,
Examples: >> isa(my_obj, any) // always returns true true >> isa(my_type, any) // always returns true true
-
union
A meta-type that means ‘either one of the given types’
Example: >> int <= union[int, string] true >> union[int, string] <= int false >> union[int, string] <= union[string, int] true
-
type
The type of types
Supertypes: any
Examples: >> type(int) == type(string) true >> int <= type(int) # int isn't a subtype of `type` false >> isa(int, type(int)) # int is an instance of `type` true
-
object
The base object type
Supertypes: any Subtypes: nulltype, primitive, container, aggregate_result[any], function, property, module, signal,
-
nulltype
The type of the singleton null. Represents SQL NULL, but behaves like Python’s None,
Supertypes: object
Examples: >> null == null true >> null + 1 [bold]TypeError[/bold]: Operator '+' not implemented for nulltype and int
-
primitive
The base type for all primitives
Supertypes: object Subtypes: text, number, bool, timestamp, datetime, date, time, t_id[table], t_relation[any],
-
text
A text type (behaves the same as string)
Supertypes: primitive Subtypes: _rich, string,
-
string
A string type (behaves the same as text)
Supertypes: text
-
number
The base type for all numbers
Supertypes: primitive Subtypes: int, float, decimal,
-
int
An integer number
Supertypes: number
-
float
A floating-point number
Supertypes: number
-
bool
A boolean, which can be either true or false
Supertypes: primitive
-
timestamp
A timestamp type (unix epoch)
Supertypes: primitive Methods:
-
datetime
A datetime type (date+time combined)
Supertypes: primitive
-
container
The base type of containers. A container holds other objects inside it.
Supertypes: object Subtypes: struct, table, aggregated[any], projected[any], json[any],
-
struct
A structure type
Supertypes: container Subtypes: row,
-
row
A row in a table. (essentially a named-tuple)
Supertypes: struct
-
table
A table type. Tables support the following operations - - Projection (or: map), using the {} operator - Selection (or: filter), using the [] operator - Slice (or: indexing), using the [..] operator - Order (or: sorting), using the order{} operator - Update, using the update{} operator - Delete, using the delete[] operator - + for concat, & for intersect, | for union
Supertypes: container Subtypes: list[item: any], set[item: any], Methods: -
add_index
(column_name, unique)¶ Add an index to the table, to optimize filtering operations. A method of the table type.
Parameters: - column_name (union[string, list[item: string]]) – The name of the column to add index
- unique (bool) – If true, every value in the column is expected to be unique (default=false)
Note: Future versions of this function will accept several columns.
Example: >> table x = [1,2,3]{item} >> x.add_index("item")
-
-
list[item: any]
A list type
Supertypes: table
-
set[item: any]
A set type, in which all elements are unique
Supertypes: table
-
t_id[table]
The type of a table id
Supertypes: primitive
-
t_relation[any]
The type of a table relation
Supertypes: primitive
-
aggregated[any]
A meta-type to signify aggregated operations, i.e. operations inside a grouping
Supertypes: container
Example: >> x = [1] >> one one x{ => repr(type(item))} "aggregated[item: int]"
-
projected[any]
A meta-type to signify projected operations, i.e. operations inside a projection.
Supertypes: container
Example: >> x = [1] >> one one x{ repr(type(item)) } "projected[item: int]"
-
json[any]
A json type
Supertypes: container Subtypes: json_array,
-
json_array
A json array type. Created by aggregation.
Supertypes: json[any]
-
function
A meta-type for all functions
Supertypes: object
-
module
A meta-type for all modules
Supertypes: object
-
signal
A meta-type for all signals (i.e. exceptions)
Supertypes: object Subtypes: Exception,