Hops¶
hops
¶
Description |
Examples |
---|---|
Arguments:
HOPS_SPEC(dict{>1})
The HOPS_SPEC is a dictionary that takes the following keys:
If multiple HOP_SPEC arguments are given, then the output of
a HOP_SPEC is passed on as the input to the next. This is a
convenient way of chaining hops together. It is mostly useful
when at least one of the HOP_SPEC arguments use recursion.
The join criteria are described by using the
eq function. All dataset aliases defined in the
datasets key have to be joined and all must by navigable
from the source entity. If that is not the case, then an error
will be raised at compile time.The
hops function produces a table inside, one column per
dataset alias. This table is the projected down into a list
of values by the return clause that is then returned by
the function.Note that the result of the
hops function is deterministic based on the
_id property of the entities processed within each dataset. I.e.. re-running a DTL transform with
a hops function using the exact same entities in the source and in the datasets in the datasets property
will yield the same order of the result. You should apply a sorted* function to the result to get a
particular order (for example on a particular property, or if you use the return keyword).Warning Hop-ing to the sink dataset is discouraged as there are some gotchas. The pipe’s |
["hops", {
"datasets": ["Address a", "Country c"],
"return": "a",
"where": [
["or",
["eq", "a.type", "SHIPPING"],
["eq", "a.type", "BILLING"]],
["eq", "_S.address", "a._id"],
["eq", "c._id", "a.country"]
]}]
Join the source entity’s
address property with the
Address ’s _id property, and then the Address ’s
country property with Country ’s _id property.
Filter the addresses by type, so that only shipping and
billing addresses are included in the result. Return the
addresses found.["hops", {
"datasets": ["Person p"],
"where": [
["eq", "_S.children", "p._id"],
["eq", "p.gender", "female"]],
"recurse": true
},
{
"datasets": ["Hobby h"],
"where": ["eq", "_S.hobbies", "h._id"],
"return": "h.name"
}]
Recursively retrieve the source entity’s daughters (and
granddaughters and so on) and then return the names of all
their hobbies. Please note that the result list is not automatically sorted on the
name property - if order
matters, a sorted function must be applied before the result is used.["hops", {
"datasets": ["orders o", "product p"],
"where": [
["eq", "_S._id", "o.customer_id"]
["eq", "o.lines.product_id", "p.product_id"]
],
"subsets": {
"o": ["eq", "_S.webshop_id", "myshop"]
}
}]
Find the products that the customer has bought from a specific web shop. This example uses the
subsets
property to reference a subset of the orders dataset, i.e. the orders placed in the myshop web shop. |
lookup-entity
¶
Description |
Examples |
---|---|
Arguments:
DATASET_ID(string{1})
ENTITY_ID(string{1})
Returns an entity in the given dataset.
|
["lookup-entity", "code-table", "foo"] Looks up the entity with the
_id property value of foo in the code-table dataset.Note that the dataset referenced has to be populated before the DTL transform can run.
If the entity doesn’t exist in the dataset,
null is returned.Warning This function does not support dependency tracking, so if the entity that is looked up changes then you may want to reset the pipe. This will not happen automatically. |