How to use the input table of a custom transformation for further operations?

Hey,
I’m trying to write a function which I use elsewhere in my query but I don’t get it working. In this configuration it complains about the pipe forward in front of mean(). If I delete the |> the error says: “missing required argument tables”. How to use the input table of the transformation for further operations? Any ideas?

aggregate_function = (t=<-) =>
    t
    t1 =
	    |> mean()
	    |>  set(key: "aggregation", value: "mean")
    t2 =
	    |>  max()
	    |>  set(key: "aggregation", value: "upperfence")
    //t3...

 union(tables: [t1,t2]) //t3,...

I managed it by myself just by adding braces and a return statement. I was just playing around and don’t really understand why it works now but maybe the solution helps someone.

aggregate_function = (t=<-) => {
        t_union = union(
          tables: [
            t |> mean() |> set(key: "aggregation", value: "mean"),
            t |> max() |> set(key: "aggregation", value: "upperfence")
            // ...
            ]
            )
        t_aggregate = 
          t_union |>pivot(rowKey: ["_field"], columnKey: ["aggregation"], valueColumn: "_value")
        return t_aggregate
    }

Then I call the function like this with |> aggregate_function().

I guess that you already figured it out by yourself, but the syntax works as follows:

|> operand is something like “from the previous table”.

some functions do not require a pipe because don’t operate on previous tables, as an example on unions and joins, you specify the tables on which to operate inside the functions.

so, to use union it should be something like t3 = union(tables: [t1,t2]) , you need to declare a new table to store the result of function that operates on the specified tables