General Functions
These functions are not tied to datatypes or aggregation like the other types of functions TQL and TQLFlow support.
Overview¶
They can be used as arguments for any parameter that takes the ANY
type.
Function | Description |
---|---|
ELEMENT |
Gets a value at given index from a list. E.g. ELEMENT(my_list, 3) |
IF |
Set a value based on a condition. E.g.IF(x GT 20 THEN 'large' ELSE 'small') . |
Examples:¶
ELEMENT¶
ELEMENT(<list-value>, <index>)
Parameter | Type | Description |
---|---|---|
list-value |
LIST-VALUE |
List from which to extract an element |
index |
INTEGER-VALUE |
0-based index at which to look for element in input-list |
Here is a basic document we can apply ELEMENT
on:
{
"item_list": ["item1", "item2", "item3"]
}
SELECT
portion for TQL or TQLFlow could look like this:
SELECT
item_list,
ELEMENT(item_list, 0) AS item
Resulting document:
{
"item_list": ["item1", "item2", "item3"],
"item": "item1"
}
Note that passing an out of bounds index would result in nothing:
SELECT
itemList,
ELEMENT(itemList, 100) AS item
Resulting document:
{
"item_list": ["item1", "item2", "item3"]
}
IF¶
IF(<condition> THEN <then-value> ELSE <else-value>)
Parameter | Type | Description |
---|---|---|
condition |
CONDITION |
Condition that determines which value to return |
then-value |
ANY |
Value to return if condition evaluates to true |
else-value |
ANY |
Value to return if condition evaluates to false |
Here are two basic documents we can apply IF
on:
[{
"name" : "BurstIQ",
"item" : "item 1"
},
{
"item" : "item 2"
}]
SELECT
portion for TQL or TQLFlow could look like this:
SELECT *,
IF(name ISNOTNULL
THEN name
ELSE "N/A") AS description
Resulting documents:
[{
"name" : "BurstIQ",
"item" : "item 1",
"description" : "An Example for IF"
},
{
"item" : "item 2",
"description" : "N/A"
}]