If one of the arguments is also a function call, it must be encased in parentheses, so we know where arguments of inner function end and the arguments of outer function start.
There is a alternative way of calling functions: using a pipeline. Regardless of whether the pipeline is delimited by pipe symbol |
or a new line, the pipeline is equivalent to applying each of functions as the last argument of the next function.
a | foo 3 | bar 'hello' 'world' | baz
baz (bar 'hello' 'world' (foo 3 a))
As you may have noticed, transforms are regular functions too!
SELECT
FROM
employees
WHERE
age > 50
ORDER BY
name
… is equivalent to …
SELECT
*
FROM
employees
WHERE
age > 50
ORDER BY
name
*
FROM
WHERE
age > 50
ORDER BY
name
… is equivalent to …
sort name (filter age > 50 (from employees))
SELECT
*
FROM
employees
WHERE
age > 50
As you can see, the first example with pipeline notation is much easier to comprehend, compared to the last one with the regular function call notation. This is why it is recommended to use pipelines for nested function calls that are 3 or more levels deep.