type_bridge.expressions.builtin¶
builtin
¶
Built-in TypeQL function expressions.
TypeQL 3.8.0 introduced built-in functions that can be used in expressions: - iid($var) - Get the internal ID of a thing - label($var) - Get the type label of a thing - abs($num) - Absolute value - ceil($num) - Round up to nearest integer - floor($num) - Round down to nearest integer - round($num) - Round to nearest integer - len($list) - Length of a list - max($a, $b, ...) - Maximum value - min($a, $b, ...) - Minimum value
BuiltinFunctionExpr
dataclass
¶
Bases: Expression
Expression for TypeQL built-in functions.
Built-in functions can be used in fetch clauses, let assignments, and other expression contexts.
Example
expr = BuiltinFunctionExpr("iid", "$e") expr.to_typeql("$e") 'iid($e)'
In a fetch clause:¶
fetch¶
Create a built-in function expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Function name (iid, label, abs, ceil, floor, round, len, max, min) |
required |
*args
|
str
|
Variable names or literal values as arguments |
()
|
Source code in type_bridge/expressions/builtin.py
to_ast
¶
Built-in functions are values, not patterns.
Use to_value_ast() instead for AST representation.
Source code in type_bridge/expressions/builtin.py
to_typeql
¶
Generate TypeQL for this built-in function call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
Ignored (built-in functions use their own args) |
required |
Returns:
| Type | Description |
|---|---|
str
|
TypeQL function call string (e.g., "iid($e)") |
Source code in type_bridge/expressions/builtin.py
to_value_ast
¶
Convert to AST FunctionCallValue.
iid
¶
Get the internal ID of a thing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
Variable name (e.g., "$e" or "e") |
required |
Returns:
| Type | Description |
|---|---|
BuiltinFunctionExpr
|
Expression that generates "iid($var)" |
Example
iid("$e").to_typeql("") 'iid($e)'
Use in fetch: fetch¶
Source code in type_bridge/expressions/builtin.py
label
¶
Get the type label of a thing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
Variable name (e.g., "$e" or "e") |
required |
Returns:
| Type | Description |
|---|---|
BuiltinFunctionExpr
|
Expression that generates "label($var)" |
Example
label("$e").to_typeql("") 'label($e)'
Use in fetch: fetch¶
Source code in type_bridge/expressions/builtin.py
abs_
¶
Get the absolute value of a number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
Variable name or numeric expression |
required |
Returns:
| Type | Description |
|---|---|
BuiltinFunctionExpr
|
Expression that generates "abs($var)" |
Source code in type_bridge/expressions/builtin.py
ceil
¶
Round up to nearest integer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
Variable name or numeric expression |
required |
Returns:
| Type | Description |
|---|---|
BuiltinFunctionExpr
|
Expression that generates "ceil($var)" |
Source code in type_bridge/expressions/builtin.py
floor
¶
Round down to nearest integer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
Variable name or numeric expression |
required |
Returns:
| Type | Description |
|---|---|
BuiltinFunctionExpr
|
Expression that generates "floor($var)" |
Source code in type_bridge/expressions/builtin.py
round_
¶
Round to nearest integer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
Variable name or numeric expression |
required |
Returns:
| Type | Description |
|---|---|
BuiltinFunctionExpr
|
Expression that generates "round($var)" |
Source code in type_bridge/expressions/builtin.py
len_
¶
Get length of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
Variable name of a list |
required |
Returns:
| Type | Description |
|---|---|
BuiltinFunctionExpr
|
Expression that generates "len($var)" |
Source code in type_bridge/expressions/builtin.py
max_
¶
Get maximum value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
str
|
Variable names or values to compare |
()
|
Returns:
| Type | Description |
|---|---|
BuiltinFunctionExpr
|
Expression that generates "max($a, $b, ...)" |
Source code in type_bridge/expressions/builtin.py
min_
¶
Get minimum value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
str
|
Variable names or values to compare |
()
|
Returns:
| Type | Description |
|---|---|
BuiltinFunctionExpr
|
Expression that generates "min($a, $b, ...)" |