Fenl Catalog v0.1.0-dev

add


πŸ§ͺ

add(a: number, b: number) -> number

Operator: a + b

Returns the sum of two numbers.

  • math

add Example 0

Input.a + Input.b

Input

timesubsortkeyab
10000A5.71.2
10011A6.30.4
10012B3.7
10021A13.2

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000A5.71.26.9
1970-01-01T00:00:00.0000010011A6.30.46.7
1970-01-01T00:00:00.0000010012B3.7
1970-01-01T00:00:00.0000010021A13.2

add_time


πŸ§ͺ

add_time(delta: timedelta, time: timestamp_ns) -> timestamp_ns

Adds a time delta (duration or interval) to a time.

  • time

add_time Example 0

Input.date | add_time(days(3))

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true11996-08-22T00:00:00.000000000
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true21996-07-23T00:00:00.000000000
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false31996-07-25T00:00:00.000000000
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true41996-06-25T00:00:00.000000000
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false51996-07-25T00:00:00.000000000
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true61996-08-25T00:00:00.000000000

ceil


πŸ§ͺ

ceil(n: number) -> number

Rounds the number up to the next largest integer.

  • math

ceil Example 0

Input.a | ceil()

Input

timesubsortkeya
10000A5.7
10011A6.3
10012B

Output

timesubsortkeyaresult
1970-01-01T00:00:00.0000010000A5.76.0
1970-01-01T00:00:00.0000010011A6.37.0
1970-01-01T00:00:00.0000010012B

clamp


πŸ§ͺ

clamp(value: number, min: number = null, max: number = null) -> number

Returns value clamped between the bounds of min and max.

πŸ“˜

Returns value if value is between min and max. Returns min if value < min. Returns max if value > max. Returns null if value is null, or if min > max. If min or max are null, then no clamping on that side will be performed.

  • math

clamp Example 0

Input.a | clamp(min = 0.5, max = 9.5)

Input

timesubsortkeyab
10000A5.71.2
10011A6.30.4
10012B3.7
10021A13.2

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000A5.71.25.7
1970-01-01T00:00:00.0000010011A6.30.46.3
1970-01-01T00:00:00.0000010012B3.7
1970-01-01T00:00:00.0000010021A13.29.5

clamp Example 1

Input.a | clamp(min = 0.5)

Input

timesubsortkeyab
10000A5.71.2
10011A6.30.4
10012B3.7
10021A13.2

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000A5.71.25.7
1970-01-01T00:00:00.0000010011A6.30.46.3
1970-01-01T00:00:00.0000010012B3.7
1970-01-01T00:00:00.0000010021A13.213.2

count


πŸ§ͺ

count(input: any, window: window = null) -> u32

Counts each distinct, non-null value across the input.

  • aggregation

count Example 0

count(Input.value)

Input

timesubsortkeyvalue
10000Ben50.7
20000Ryan
30000Ryan67.2
40000Ben1.2
50000Ben
60000Ryan2.3

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Ben50.71
1970-01-01T00:00:00.0000020000Ryan0
1970-01-01T00:00:00.0000030000Ryan67.21
1970-01-01T00:00:00.0000040000Ben1.22
1970-01-01T00:00:00.0000050000Ben2
1970-01-01T00:00:00.0000060000Ryan2.32

daily


πŸ§ͺ

daily() -> bool

A periodic function that produces a boolean value that is true at the start of each calendar day (UTC).

  • window

daily Example 0

sum(Input.n, since(daily()))

Input

timesubsortkeyn
1996-12-19T00:00:00-00:000Ben1
1996-12-19T00:00:00-00:000Ryan2
1996-12-20T00:00:00-00:000Ben3
1996-12-20T01:00:00-00:000Ben4
1996-12-21T00:00:00-00:000Ryan5
1996-12-21T00:00:00-00:000Ben6

Output

timesubsortkeynresult
1996-12-19T00:00:00.0000000000Ben11
1996-12-19T00:00:00.0000000000Ryan22
1996-12-19T00:00:00.00000000018446744073709551615Ben1
1996-12-19T00:00:00.00000000018446744073709551615Ryan2
1996-12-20T00:00:00.0000000000Ben33
1996-12-20T00:00:00.00000000018446744073709551615Ben3
1996-12-20T00:00:00.00000000018446744073709551615Ryan
1996-12-20T01:00:00.0000000000Ben44
1996-12-21T00:00:00.0000000000Ben610
1996-12-21T00:00:00.0000000000Ryan55

day_of_month


πŸ§ͺ

day_of_month(time: timestamp_ns) -> u32

Return the day-of-month for the given time, starting with 1.

  • time

day_of_month Example 0

day_of_month(Input.date)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true119
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true220
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false322
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true422
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false522
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true622

day_of_month0


πŸ§ͺ

day_of_month0(time: timestamp_ns) -> u32

Return the day-of-month for the given time, starting with 0.

  • time

day_of_month0 Example 0

day_of_month0(Input.date)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true118
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true219
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false321
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true421
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false521
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true621

day_of_year


πŸ§ͺ

day_of_year(time: timestamp_ns) -> u32

Return the day-of-year for the given time, starting with 1.

  • time

day_of_year Example 0

day_of_year(Input.date)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true1232
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true2202
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false3204
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true4174
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false5204
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true6235

day_of_year0


πŸ§ͺ

day_of_year0(time: timestamp_ns) -> u32

Return the day-of-year for the given time, starting with 0.

  • time

day_of_year0 Example 0

day_of_year0(Input.date)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true1231
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true2201
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false3203
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true4173
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false5203
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true6234

days


πŸ§ͺ

days(days: i64) -> interval_days

Produces an interval corresponding to the given number of calendar days.

πŸ“˜

NOTE: While the argument takes an i64 negative numbers of days and values greater than i32::MAX produce null intervals.

  • time

days Example 0

Input.date | add_time(days(3))

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true11996-08-22T00:00:00.000000000
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true21996-07-23T00:00:00.000000000
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false31996-07-25T00:00:00.000000000
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true41996-06-25T00:00:00.000000000
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false51996-07-25T00:00:00.000000000
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true61996-08-25T00:00:00.000000000

days_between


πŸ§ͺ

days_between(t1: timestamp_ns, t2: timestamp_ns) -> interval_days

Returns the number of days between the first and second timestamp

πŸ“˜

If the first timestamp is greater than the second, the result will be a positive interval. If the second timestamp is greater than the first, the result with be a negative interval. This function returns an interval, so it can be used with the add_time function. It can be returned as a column by converting it as i32.

  • time

days_between Example 0

days_between(Input.time, Input.date) as i32

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true1151
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true290
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false362
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true41
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false51
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true61

div


πŸ§ͺ

div(a: number, b: number) -> number

Operator: a / b

Returns the division of two numbers.

πŸ“˜

Note: The result of dividing two numbers maintains the type of number. Numeric values are promoted to be compatible, for instance x / 2.0 would promote x to f64.

  • math

div Example 0

Input.a / Input.b

Input

timesubsortkeyab
10000A5.71.2
10011A6.30.4
10012B3.7
10021A13.2

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000A5.71.24.75
1970-01-01T00:00:00.0000010011A6.30.415.749999999999998
1970-01-01T00:00:00.0000010012B3.7
1970-01-01T00:00:00.0000010021A13.2

else


πŸ§ͺ

else(default: any, value: any) -> any

Return the value if it is not null, default otherwise.

  • logical

else Example 0

Input.a | else(Input.b)

Input

timesubsortkeyab
10000X57.863
20000Y86.3
30000X6873
40000X

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000X57.863.057.8
1970-01-01T00:00:00.0000020000Y86.386.3
1970-01-01T00:00:00.0000030000X6873.06873.0
1970-01-01T00:00:00.0000040000X

else Example 1

Input.a | else(42.0)

Input

timesubsortkeyab
10000X57.863
20000Y86.3
30000X6873
40000X

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000X57.863.057.8
1970-01-01T00:00:00.0000020000Y86.342.0
1970-01-01T00:00:00.0000030000X6873.06873.0
1970-01-01T00:00:00.0000040000X42.0

eq


πŸ§ͺ

eq(a: any, b: any) -> bool

Operator: a == b

Return true if a is equal to b.

  • comparison

eq Example 0

Input.a == Input.b

Input

timesubsortkeyab
10000Ben50.76.0
20000Ryan70
30000Ryan67.271.3
40000Ben1.2
50000Ben
60000Ryan2.368.7

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000Ben50.76.0false
1970-01-01T00:00:00.0000020000Ryan70.0
1970-01-01T00:00:00.0000030000Ryan67.271.3false
1970-01-01T00:00:00.0000040000Ben1.2
1970-01-01T00:00:00.0000050000Ben
1970-01-01T00:00:00.0000060000Ryan2.368.7false

exp


πŸ§ͺ

exp(power: f64) -> f64

Returns e^power.

πŸ“˜

The exponential function applies to f64 numbers only. Other numbers will be promoted appropriately.

  • math

exp Example 0

exp(Input.a)

Input

timesubsortkeya
10000A5.7
10011A6.3
10012B

Output

timesubsortkeyaresult
1970-01-01T00:00:00.0000010000A5.7298.8674009670603
1970-01-01T00:00:00.0000010011A6.3544.571910125929
1970-01-01T00:00:00.0000010012B

first


πŸ§ͺ

first(input: any, window: window = null) -> any

Computes the first value present across the input.

πŸ“˜

NOTE: The first value is inclusive of any values at the current time.

  • aggregation

first Example 0

first(Input.value)

Input

timesubsortkeyvalue
10000Ben50.7
20000Ryan
30000Ryan67.2
40000Ben1.2
50000Ben
60000Ryan2.3

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Ben50.750.7
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000Ryan67.267.2
1970-01-01T00:00:00.0000040000Ben1.250.7
1970-01-01T00:00:00.0000050000Ben50.7
1970-01-01T00:00:00.0000060000Ryan2.367.2

floor


πŸ§ͺ

floor(n: number) -> number

Rounds the number down to the next smallest integer.

  • math

floor Example 0

Input.a | floor()

Input

timesubsortkeya
10000A5.7
10011A6.3
10012B

Output

timesubsortkeyaresult
1970-01-01T00:00:00.0000010000A5.75.0
1970-01-01T00:00:00.0000010011A6.36.0
1970-01-01T00:00:00.0000010012B

gt


πŸ§ͺ

gt(a: ordered, b: ordered) -> bool

Operator: a > b

Return true if a is greater than b.

  • comparison

gt Example 0

Input.a > Input.b

Input

timesubsortkeyab
10000Ben50.76.0
20000Ryan70
30000Ryan67.271.3
40000Ben1.2
50000Ben
60000Ryan2.368.7

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000Ben50.76.0true
1970-01-01T00:00:00.0000020000Ryan70.0
1970-01-01T00:00:00.0000030000Ryan67.271.3false
1970-01-01T00:00:00.0000040000Ben1.2
1970-01-01T00:00:00.0000050000Ben
1970-01-01T00:00:00.0000060000Ryan2.368.7false

gte


πŸ§ͺ

gte(a: ordered, b: ordered) -> bool

Operator: a >= b

Return true if a is greater than or equal to b.

  • comparison

gte Example 0

Input.a >= Input.b

Input

timesubsortkeyab
10000Ben50.76.0
20000Ryan70
30000Ryan67.271.3
40000Ben1.2
50000Ben
60000Ryan2.368.7

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000Ben50.76.0true
1970-01-01T00:00:00.0000020000Ryan70.0
1970-01-01T00:00:00.0000030000Ryan67.271.3false
1970-01-01T00:00:00.0000040000Ben1.2
1970-01-01T00:00:00.0000050000Ben
1970-01-01T00:00:00.0000060000Ryan2.368.7false

hash


πŸ§ͺ

hash(input: any) -> u64

Returns the hash of the input.

  • misc

hash Example 0

hash(Input.value)

Input

timesubsortkeyvalue
10000Benhello
20000Ryan
30000Ryanworld
40000Benhi
50000Ben
60000Ryanearth

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Benhello15811883632611753650
1970-01-01T00:00:00.0000020000Ryan5927736130248593597
1970-01-01T00:00:00.0000030000Ryanworld10724100356298933117
1970-01-01T00:00:00.0000040000Benhi8732440231931982831
1970-01-01T00:00:00.0000050000Ben5927736130248593597
1970-01-01T00:00:00.0000060000Ryanearth2958664733073760318

hourly


πŸ§ͺ

hourly() -> bool

A periodic function that produces a boolean value that is true at the start of each hour.

  • window

hourly Example 0

sum(Input.n, since(hourly()))

Input

timesubsortkeyn
1996-12-19T16:00:57-00:000Ben2
1996-12-19T16:00:58-00:000Ryan3
1996-12-19T17:00:59-00:000Ben6
1996-12-19T17:01:00-00:000Ben9
1996-12-19T17:01:00-00:000Ryan8
1996-12-19T18:00:00-00:000Ben1

Output

timesubsortkeynresult
1996-12-19T16:00:57.0000000000Ben22
1996-12-19T16:00:58.0000000000Ryan33
1996-12-19T17:00:00.00000000018446744073709551615Ben2
1996-12-19T17:00:00.00000000018446744073709551615Ryan3
1996-12-19T17:00:59.0000000000Ben66
1996-12-19T17:01:00.0000000000Ben915
1996-12-19T17:01:00.0000000000Ryan88
1996-12-19T18:00:00.0000000000Ben116

if


πŸ§ͺ

if(condition: bool, value: any) -> any

Return the value if condition is true, null otherwise.

  • logical

if Example 0

Input.value | if(Input.condition)

Input

timesubsortkeyvaluecondition
10000A57.8false
20000B58.7true
30000Atrue
40000A876
50000A786.0

Output

timesubsortkeyvalueconditionresult
1970-01-01T00:00:00.0000010000A57.8false
1970-01-01T00:00:00.0000020000B58.7true58.7
1970-01-01T00:00:00.0000030000Atrue
1970-01-01T00:00:00.0000040000A876.0
1970-01-01T00:00:00.0000050000A786.0

is_valid


πŸ§ͺ

is_valid(input: any) -> bool

Returns true if input is not null.

  • misc

is_valid Example 0

is_valid(Input.value)

Input

timesubsortkeyvalue
10000Benhello
20000Ryan
30000Ryanworld
40000Benhi
50000Ben
60000Ryanearth

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Benhellotrue
1970-01-01T00:00:00.0000020000Ryantrue
1970-01-01T00:00:00.0000030000Ryanworldtrue
1970-01-01T00:00:00.0000040000Benhitrue
1970-01-01T00:00:00.0000050000Bentrue
1970-01-01T00:00:00.0000060000Ryanearthtrue

lag


πŸ§ͺ

lag(e: ordered, n: i64) -> ordered

Returns a lagging value of e.

πŸ“˜

Returns the lagging value of the expression e. n indicates how far back the value is drawn from. For instance n = 1 is the previous value. n = 2 is the value before that.

  • time

lag Example 0

lag(Input.n, 1)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false32
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true43
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false51
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true65

lag Example 1

mean(Input.n - lag(Input.n, 1))

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false31.0
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true41.0
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false54.0
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true62.5

last


πŸ§ͺ

last(input: any, window: window = null) -> any

Computes the last value present across the input.

πŸ“˜

NOTE: The last value is inclusive of any values at the current time.

  • aggregation

last Example 0

last(Input.value)

Input

timesubsortkeyvalue
10000Ben50.7
20000Ryan
30000Ryan67.2
40000Ben1.2
50000Ben
60000Ryan2.3

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Ben50.750.7
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000Ryan67.267.2
1970-01-01T00:00:00.0000040000Ben1.21.2
1970-01-01T00:00:00.0000050000Ben1.2
1970-01-01T00:00:00.0000060000Ryan2.32.3

len


πŸ§ͺ

len(s: string) -> i32

Returns the length of the string s.

  • string

len Example 0

Input.value | len()

Input

timesubsortkeyvalue
10000BenHello World
20000Ryan
30000RyanHi Earth
40000BenHello
50000Ben
60000Ryanhi

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000BenHello World11
1970-01-01T00:00:00.0000020000Ryan0
1970-01-01T00:00:00.0000030000RyanHi Earth8
1970-01-01T00:00:00.0000040000BenHello5
1970-01-01T00:00:00.0000050000Ben0
1970-01-01T00:00:00.0000060000Ryanhi2

logical_and


πŸ§ͺ

logical_and(a: bool, b: bool) -> bool

Operator: a and b

Returns the logical conjunction (AND) of two booleans.

  • logical

logical_and Example 0

Input.a and Input.b

Input

timesubsortkeyab
10000Atruefalse
20000Btruetrue
30000Afalsetrue
40000Afalsefalse
50000Atrue
60000Btrue
70000Afalse
80000Bfalse

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000Atruefalsefalse
1970-01-01T00:00:00.0000020000Btruetruetrue
1970-01-01T00:00:00.0000030000Afalsetruefalse
1970-01-01T00:00:00.0000040000Afalsefalsefalse
1970-01-01T00:00:00.0000050000Atrue
1970-01-01T00:00:00.0000060000Btrue
1970-01-01T00:00:00.0000070000Afalse
1970-01-01T00:00:00.0000080000Bfalse

logical_or


πŸ§ͺ

logical_or(a: bool, b: bool) -> bool

Operator: a or b

Returns the logical disjunction (OR) of two booleans.

  • logical

logical_or Example 0

Input.a or Input.b

Input

timesubsortkeyab
10000Atruefalse
20000Btruetrue
30000Afalsetrue
40000Afalsefalse
50000Atrue
60000Btrue
70000Afalse
80000Bfalse

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000Atruefalsetrue
1970-01-01T00:00:00.0000020000Btruetruetrue
1970-01-01T00:00:00.0000030000Afalsetruetrue
1970-01-01T00:00:00.0000040000Afalsefalsefalse
1970-01-01T00:00:00.0000050000Atrue
1970-01-01T00:00:00.0000060000Btrue
1970-01-01T00:00:00.0000070000Afalse
1970-01-01T00:00:00.0000080000Bfalse

lower


πŸ§ͺ

lower(s: string) -> string

Converts the string to lower case.

  • string

lower Example 0

Input.value | lower()

Input

timesubsortkeyvalue
10000BenHello World
20000Ryan
30000RyanHi Earth
40000BenHello
50000Ben
60000Ryanhi

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000BenHello Worldhello world
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000RyanHi Earthhi earth
1970-01-01T00:00:00.0000040000BenHellohello
1970-01-01T00:00:00.0000050000Ben
1970-01-01T00:00:00.0000060000Ryanhihi

lt


πŸ§ͺ

lt(a: ordered, b: ordered) -> bool

Operator: a < b

Return true if a is less than b.

  • comparison

lt Example 0

Input.a < Input.b

Input

timesubsortkeyab
10000Ben50.76.0
20000Ryan70
30000Ryan67.271.3
40000Ben1.2
50000Ben
60000Ryan2.368.7

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000Ben50.76.0false
1970-01-01T00:00:00.0000020000Ryan70.0
1970-01-01T00:00:00.0000030000Ryan67.271.3true
1970-01-01T00:00:00.0000040000Ben1.2
1970-01-01T00:00:00.0000050000Ben
1970-01-01T00:00:00.0000060000Ryan2.368.7true

lte


πŸ§ͺ

lte(a: ordered, b: ordered) -> bool

Operator: a < b

Return true if a is less than or equal to b.

  • comparison

lte Example 0

Input.a <= Input.b

Input

timesubsortkeyab
10000Ben50.76.0
20000Ryan70
30000Ryan67.271.3
40000Ben1.2
50000Ben
60000Ryan2.368.7

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000Ben50.76.0false
1970-01-01T00:00:00.0000020000Ryan70.0
1970-01-01T00:00:00.0000030000Ryan67.271.3true
1970-01-01T00:00:00.0000040000Ben1.2
1970-01-01T00:00:00.0000050000Ben
1970-01-01T00:00:00.0000060000Ryan2.368.7true

max


πŸ§ͺ

max(input: ordered, window: window = null) -> ordered

Computes the maximum of values across the input.

  • aggregation * math

max Example 0

max(Input.value)

Input

timesubsortkeyvalue
10000Ben50.7
20000Ryan
30000Ryan67.2
40000Ben1.2
50000Ben
60000Ryan2.3

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Ben50.750.7
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000Ryan67.267.2
1970-01-01T00:00:00.0000040000Ben1.250.7
1970-01-01T00:00:00.0000050000Ben50.7
1970-01-01T00:00:00.0000060000Ryan2.367.2

mean


πŸ§ͺ

mean(input: number, window: window = null) -> f64

Computes the arithmetic mean of values across the input.

  • aggregation * math

mean Example 0

mean(Input.value)

Input

timesubsortkeyvalue
10000Ben50.7
20000Ryan
30000Ryan67.2
40000Ben1.2
50000Ben
60000Ryan2.3

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Ben50.750.7
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000Ryan67.267.2
1970-01-01T00:00:00.0000040000Ben1.225.950000000000003
1970-01-01T00:00:00.0000050000Ben25.950000000000003
1970-01-01T00:00:00.0000060000Ryan2.334.75

min


πŸ§ͺ

min(input: ordered, window: window = null) -> ordered

Computes the minimum of values across the input.

  • aggregation * math

min Example 0

min(Input.value)

Input

timesubsortkeyvalue
10000Ben50.7
20000Ryan
30000Ryan67.2
40000Ben1.2
50000Ben
60000Ryan2.3

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Ben50.750.7
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000Ryan67.267.2
1970-01-01T00:00:00.0000040000Ben1.21.2
1970-01-01T00:00:00.0000050000Ben1.2
1970-01-01T00:00:00.0000060000Ryan2.32.3

month_of_year


πŸ§ͺ

month_of_year(time: timestamp_ns) -> u32

Return the month-of-year for the given time, startiing with 1.

πŸ“˜

This is 1 indexed, with January corresponding to 1.

  • time

month_of_year Example 0

month_of_year(Input.date)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true18
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true27
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false37
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true46
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false57
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true68

month_of_year0


πŸ§ͺ

month_of_year0(time: timestamp_ns) -> u32

Return the month-of-year for the given time, startiing with 0.

πŸ“˜

This is 0 indexed, with January corresponding to 0.

  • time

month_of_year0 Example 0

month_of_year0(Input.date)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true17
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true26
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false36
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true45
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false56
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true67

monthly


πŸ§ͺ

monthly() -> bool

A periodic function that produces a boolean value that is true at the start of each calendar month (UTC).

  • window

monthly Example 0

sum(Input.n, since(monthly()))

Input

timesubsortkeyn
1996-02-19T16:00:00-00:000Ben2
1996-02-19T16:00:00-00:000Ryan3
1996-04-20T16:00:00-00:000Ben6
1996-04-20T16:01:00-00:000Ben9
1996-04-21T16:00:00-00:000Ryan8
1996-05-21T16:00:00-00:000Ben1

Output

timesubsortkeynresult
1996-02-19T16:00:00.0000000000Ben22
1996-02-19T16:00:00.0000000000Ryan33
1996-03-01T00:00:00.00000000018446744073709551615Ben2
1996-03-01T00:00:00.00000000018446744073709551615Ryan3
1996-04-01T00:00:00.00000000018446744073709551615Ben
1996-04-01T00:00:00.00000000018446744073709551615Ryan
1996-04-20T16:00:00.0000000000Ben66
1996-04-20T16:01:00.0000000000Ben915
1996-04-21T16:00:00.0000000000Ryan88
1996-05-01T00:00:00.00000000018446744073709551615Ben15
1996-05-01T00:00:00.00000000018446744073709551615Ryan8
1996-05-21T16:00:00.0000000000Ben11

months


πŸ§ͺ

months(months: i64) -> interval_months

Produces an interval corresponding to the given number of calendar months.

πŸ“˜

NOTE: While the argument takes an i64 values outside the range of i32 produce null intervals.

  • time

months Example 0

Input.date | add_time(months(3))

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true11996-11-19T00:00:00.000000000
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true21996-10-20T00:00:00.000000000
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false31996-10-22T00:00:00.000000000
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true41996-09-22T00:00:00.000000000
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false51996-10-22T00:00:00.000000000
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true61996-11-22T00:00:00.000000000

months_between


πŸ§ͺ

months_between(t1: timestamp_ns, t2: timestamp_ns) -> interval_months

Returns the number of months between the first and second timestamp

πŸ“˜

If the first timestamp is greater than the second, the result will be a positive interval. If the second timestamp is greater than the first, the result with be a negative interval. This function returns an interval, so it can be used with the add_time function. It can be returned as a column by converting it as i32.

  • time

months_between Example 0

months_between(Input.time, Input.date) as i32

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true15
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true23
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false32
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true40
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false50
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true60

mul


πŸ§ͺ

mul(a: number, b: number) -> number

Operator: a * b

Returns the product of two numbers.

  • math

mul Example 0

Input.a * Input.b

Input

timesubsortkeyab
10000A5.71.2
10011A6.30.4
10012B3.7
10021A13.2

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000A5.71.26.84
1970-01-01T00:00:00.0000010011A6.30.42.52
1970-01-01T00:00:00.0000010012B3.7
1970-01-01T00:00:00.0000010021A13.2

neg


πŸ§ͺ

neg(n: signed) -> signed

Operator: -n

Returns the negation of n.

  • math

neg Example 0

-Input.a

Input

timesubsortkeya
10000A5.7
10011A6.3
10012B

Output

timesubsortkeyaresult
1970-01-01T00:00:00.0000010000A5.7-5.7
1970-01-01T00:00:00.0000010011A6.3-6.3
1970-01-01T00:00:00.0000010012B

neq


πŸ§ͺ

neq(a: any, b: any) -> bool

Operator: a <> b

Return true if a is not equal to b.

  • comparison

neq Example 0

Input.a <> Input.b

Input

timesubsortkeyab
10000Ben50.76.0
20000Ryan70
30000Ryan67.271.3
40000Ben1.2
50000Ben
60000Ryan2.368.7

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000Ben50.76.0true
1970-01-01T00:00:00.0000020000Ryan70.0
1970-01-01T00:00:00.0000030000Ryan67.271.3true
1970-01-01T00:00:00.0000040000Ben1.2
1970-01-01T00:00:00.0000050000Ben
1970-01-01T00:00:00.0000060000Ryan2.368.7true

not


πŸ§ͺ

not(input: bool) -> bool

Operator: !input

Returns the logical negation of a boolean.

  • logical

not Example 0

!Input.a

Input

timesubsortkeyab
10000Atruefalse
20000Btruetrue
30000Afalsetrue
40000Afalsefalse
50000Atrue
60000Btrue
70000Afalse
80000Bfalse

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000Atruefalsefalse
1970-01-01T00:00:00.0000020000Btruetruefalse
1970-01-01T00:00:00.0000030000Afalsetruetrue
1970-01-01T00:00:00.0000040000Afalsefalsetrue
1970-01-01T00:00:00.0000050000Atrue
1970-01-01T00:00:00.0000060000Btruefalse
1970-01-01T00:00:00.0000070000Afalse
1970-01-01T00:00:00.0000080000Bfalsetrue

null_if


πŸ§ͺ

null_if(condition: bool, value: any) -> any

Return the value if condition is false, null otherwise.

  • logical

null_if Example 0

Input.value | null_if(Input.condition)

Input

timesubsortkeyvaluecondition
10000A57.8false
20000B58.7true
30000Atrue
40000A876
50000A786.0

Output

timesubsortkeyvalueconditionresult
1970-01-01T00:00:00.0000010000A57.8false57.8
1970-01-01T00:00:00.0000020000B58.7true
1970-01-01T00:00:00.0000030000Atrue
1970-01-01T00:00:00.0000040000A876.0
1970-01-01T00:00:00.0000050000A786.0

powf


πŸ§ͺ

powf(base: f64, power: f64) -> f64

Returns base^power.

πŸ“˜

The power function applies to f64 numbers only. Other numbers will be promoted appropriately.

  • math

powf Example 0

powf(Input.a, Input.b)

Input

timesubsortkeyab
10000A5.71.2
10011A6.30.4
10012B3.7
10021A13.2

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000A5.71.28.073276500106656
1970-01-01T00:00:00.0000010011A6.30.42.0880275269924504
1970-01-01T00:00:00.0000010012B3.7
1970-01-01T00:00:00.0000010021A13.2

round


πŸ§ͺ

round(n: number) -> number

Rounds the number to the nearest integer.

πŸ“˜

Note: Rounds half-way numbers away from 0. For example, 0.5 rounds to 1.0 and -0.5 rounds to -1.0.

  • math

round Example 0

Input.a | round()

Input

timesubsortkeya
10000A5.7
10011A6.3
10012B

Output

timesubsortkeyaresult
1970-01-01T00:00:00.0000010000A5.76.0
1970-01-01T00:00:00.0000010011A6.36.0
1970-01-01T00:00:00.0000010012B

seconds


πŸ§ͺ

seconds(seconds: i64) -> duration_s

Produces a duration corresponding to the given number of seconds.

  • time

seconds Example 0

Input.date | add_time(seconds(3))

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true11996-08-19T00:00:03.000000000
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true21996-07-20T00:00:03.000000000
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false31996-07-22T00:00:03.000000000
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true41996-06-22T00:00:03.000000000
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false51996-07-22T00:00:03.000000000
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true61996-08-22T00:00:03.000000000

seconds_between


πŸ§ͺ

seconds_between(t1: timestamp_ns, t2: timestamp_ns) -> duration_s

Returns the number of seconds between the first and second timestamp

πŸ“˜

If the first timestamp is greater than the second, the result will be a positive duration. If the second timestamp is greater than the first, the result with be a negative interval. This function returns a duration, so it can be used with the add_time function. It can be returned as a column by converting it as i64.

  • time

seconds_between Example 0

seconds_between(Input.time, Input.date) as i64

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true113046400
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true27776000
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false35356800
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true486400
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false586400
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true686400

shift_to


πŸ§ͺ

shift_to(time: timestamp_ns, value: any) -> any

Produces the current value shifted forward to the given time.

πŸ“˜

If multiple values for the same group key are shifted to the same time all of them will be emitted in the order they originally appeared. New subsort IDs will be assigned to each row.

  • time

shift_to Example 0

Input.n | shift_to(Input.date)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true4
1996-06-22T00:00:00.0000000000Ryan4
1996-07-20T00:00:00.0000000001Ryan2
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false5
1996-07-22T00:00:00.0000000000Ben5
1996-07-22T00:00:00.0000000001Ryan3
1996-08-19T00:00:00.0000000002Ben1
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true6
1996-08-22T00:00:00.0000000003Ben6

shift_until


πŸ§ͺ

shift_until(predicate: bool, value: any) -> any

Produces the value shifted forward to the time the predicate is true

πŸ“˜

If multiple values for the same group key are shifted to the same time, all of them will be emitted in the order they originally appeared. New subsort IDs will be assigned to each row. A value may be produced at the same time it occurs if the predicate evaluates to true at that time.

  • time

shift_until Example 0

Input.n | shift_until(Input.n > 3)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true42
1996-06-21T00:00:00.0000000001Ryan3
1996-06-21T00:00:00.0000000002Ryan4
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false5
1996-07-21T00:00:00.0000000003Ben1
1996-07-21T00:00:00.0000000004Ben5
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true6
1996-08-21T00:00:00.0000000005Ben6

since


πŸ§ͺ

since(a: bool) -> window

Creates a window each time the predicate evaluates to true.

πŸ“˜

A since window can be used to perform non-overlapping windowed aggregations since some event or predicate. For example, count(Input, since(daily())) will produce the count of Input events since the start of the day. Similarly, count(Input, since(Input.n > 5)) will produce the count of Inputevents since the last timeInput.n` is greater than 5. Only one window will exist at any given time

  • window

since Example 0

count(Input, since(daily()))

Input

timesubsortkeyn
1996-12-19T16:00:57-00:000Ben2
1996-12-19T16:00:58-00:000Ryan3
1996-12-19T17:00:59-00:000Ben6
1996-12-19T17:01:00-00:000Ben9
1996-12-19T17:01:00-00:000Ryan8
1996-12-19T18:00:00-00:000Ben1

Output

timesubsortkeynresult
1996-12-19T16:00:57.0000000000Ben21
1996-12-19T16:00:58.0000000000Ryan31
1996-12-19T17:00:59.0000000000Ben62
1996-12-19T17:01:00.0000000000Ben93
1996-12-19T17:01:00.0000000000Ryan82
1996-12-19T18:00:00.0000000000Ben14

since Example 1

count(Input, since(Input.n > 5))

Input

timesubsortkeyn
1996-12-19T16:00:57-00:000Ben2
1996-12-19T16:00:58-00:000Ryan3
1996-12-19T17:00:59-00:000Ben6
1996-12-19T17:01:00-00:000Ben9
1996-12-19T17:01:00-00:000Ryan8
1996-12-19T18:00:00-00:000Ben1

Output

timesubsortkeynresult
1996-12-19T16:00:57.0000000000Ben21
1996-12-19T16:00:58.0000000000Ryan31
1996-12-19T17:00:59.0000000000Ben62
1996-12-19T17:01:00.0000000000Ben91
1996-12-19T17:01:00.0000000000Ryan82
1996-12-19T18:00:00.0000000000Ben11

sliding


πŸ§ͺ

sliding(duration: i64, window: bool) -> window

Creates a window each time the window predicate evaluates to true. The duration indicates how many windows are kept.

πŸ“˜

A sliding window can be used to perform windowed aggregations over periodic times using functions such as daily(). It can also be used to perform windowed aggregations over the previous n events or conditions, such as mean(Input.n, sliding(3, is_valid(n))), or sum(Input.n, sliding(3, Input.n > 0))). Note that the aggregation will produce a value for each new input it receives and for each time the window predicate evaluates to true. Since multiple windows may exist at any given time, only the value of the oldest existing window is output for each new event that is added to the existing windows.

  • window

sliding Example 0

sum(Input.n, sliding(2, daily()))

Input

timesubsortkeyn
1996-12-19T00:00:00-00:000Ben1
1996-12-19T00:00:00-00:000Ryan2
1996-12-20T00:00:00-00:000Ben3
1996-12-20T01:00:00-00:000Ben4
1996-12-21T00:00:00-00:000Ryan5
1996-12-21T00:00:00-00:000Ben6

Output

timesubsortkeynresult
1996-12-19T00:00:00.0000000000Ben11
1996-12-19T00:00:00.0000000000Ryan22
1996-12-19T00:00:00.00000000018446744073709551615Ben1
1996-12-19T00:00:00.00000000018446744073709551615Ryan2
1996-12-20T00:00:00.0000000000Ben34
1996-12-20T00:00:00.00000000018446744073709551615Ben4
1996-12-20T00:00:00.00000000018446744073709551615Ryan2
1996-12-20T01:00:00.0000000000Ben47
1996-12-21T00:00:00.0000000000Ben613
1996-12-21T00:00:00.0000000000Ryan55

sliding Example 1

mean(Input.n, sliding(3, is_valid(Input)))

Input

timesubsortkeyn
1996-12-19T00:00:00-00:000Ben1
1996-12-19T00:00:00-00:000Ryan2
1996-12-20T00:00:00-00:000Ben3
1996-12-20T01:00:00-00:000Ben4
1996-12-21T00:00:00-00:000Ryan5
1996-12-21T00:00:00-00:000Ben6

Output

timesubsortkeynresult
1996-12-19T00:00:00.0000000000Ben11.0
1996-12-19T00:00:00.0000000000Ryan22.0
1996-12-20T00:00:00.0000000000Ben32.0
1996-12-20T01:00:00.0000000000Ben42.6666666666666665
1996-12-21T00:00:00.0000000000Ben64.333333333333333
1996-12-21T00:00:00.0000000000Ryan53.5

sliding Example 2

sum(Input.n, sliding(3, Input.n > 0))

Input

timesubsortkeyn
1996-12-19T00:00:00-00:000Ben1
1996-12-19T00:00:00-00:000Ryan2
1996-12-20T00:00:00-00:000Ben3
1996-12-20T01:00:00-00:000Ben4
1996-12-21T00:00:00-00:000Ryan5
1996-12-21T00:00:00-00:000Ben6

Output

timesubsortkeynresult
1996-12-19T00:00:00.0000000000Ben11
1996-12-19T00:00:00.0000000000Ryan22
1996-12-20T00:00:00.0000000000Ben34
1996-12-20T01:00:00.0000000000Ben48
1996-12-21T00:00:00.0000000000Ben613
1996-12-21T00:00:00.0000000000Ryan57

sqrt


πŸ§ͺ

sqrt(a: number) -> f64

Returns the square root of a.

  • math

sqrt Example 0

sqrt(Input.a)

Input

timesubsortkeya
10000A5.7
10011A6.3
10012B

Output

timesubsortkeyaresult
1970-01-01T00:00:00.0000010000A5.72.3874672772626644
1970-01-01T00:00:00.0000010011A6.32.5099800796022267
1970-01-01T00:00:00.0000010012B

stddev


πŸ§ͺ

stddev(input: number, window: window = null) -> f64

Computes the sample standard deviation of values across the input.

πŸ“˜

This takes the square root of the sample variance formula, which divides by the number of values minus 1, rather than the population variance which divides by the number of values.

  • aggregation * math

stddev Example 0

stddev(Input.value)

Input

timesubsortkeyvalue
10000Ben50.7
20000Ryan
30000Ryan67.2
40000Ben1.2
50000Ben
60000Ryan2.3

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Ben50.7
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000Ryan67.2
1970-01-01T00:00:00.0000040000Ben1.224.750000000000004
1970-01-01T00:00:00.0000050000Ben24.750000000000004
1970-01-01T00:00:00.0000060000Ryan2.332.45

sub


πŸ§ͺ

sub(a: number, b: number) -> number

Operator: a - b

Returns the difference of two numbers.

  • math

sub Example 0

Input.a - Input.b

Input

timesubsortkeyab
10000A5.71.2
10011A6.30.4
10012B3.7
10021A13.2

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000A5.71.24.5
1970-01-01T00:00:00.0000010011A6.30.45.8999999999999995
1970-01-01T00:00:00.0000010012B3.7
1970-01-01T00:00:00.0000010021A13.2

substring


πŸ§ͺ

substring(s: string, start: i64 = null, end: i64 = null) -> string

Takes a substring of the input bounded by the start and end indices.

πŸ“˜

Note: start is inclusive and end is exclusive. The start and end may be left null to indicate the first and last indices of the string respectively. Negative indices may be passed, and are interpreted as counting backwards from the end of the string. E.g. str[-1] == str[length-1]. If end > start, an empty string is returned.

  • string

substring Example 0

Input.value | substring(start = -3)

Input

timesubsortkeyvalue
10000BenHello World
20000Ryan
30000RyanHi Earth
40000BenHello
50000Ben
60000Ryanhi

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000BenHello Worldrld
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000RyanHi Earthrth
1970-01-01T00:00:00.0000040000BenHellollo
1970-01-01T00:00:00.0000050000Ben
1970-01-01T00:00:00.0000060000Ryanhi

substring Example 1

Input.value | substring(start = 3, end = -3)

Input

timesubsortkeyvalue
10000BenHello World
20000Ryan
30000RyanHi Earth
40000BenHello
50000Ben
60000Ryanhi

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000BenHello Worldlo Wo
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000RyanHi EarthEa
1970-01-01T00:00:00.0000040000BenHello
1970-01-01T00:00:00.0000050000Ben
1970-01-01T00:00:00.0000060000Ryanhi

sum


πŸ§ͺ

sum(input: number, window: window = null) -> number

Computes the sum of values across the input.

  • aggregation * math

sum Example 0

sum(Input.value)

Input

timesubsortkeyvalue
10000Ben50.7
20000Ryan
30000Ryan67.2
40000Ben1.2
50000Ben
60000Ryan2.3

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Ben50.750.7
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000Ryan67.267.2
1970-01-01T00:00:00.0000040000Ben1.251.900000000000006
1970-01-01T00:00:00.0000050000Ben51.900000000000006
1970-01-01T00:00:00.0000060000Ryan2.369.5

time_of


πŸ§ͺ

time_of(input: any) -> timestamp_ns

Returns the timestamp of the input.

πŸ“˜

Returns the time the input, a non-literal expression, produces values. Time is measured as a Unix epoch, counting the seconds from 00:00:00.000 on 1 January 1970, excluding leap seconds as a 64-bit integer.

  • time

time_of Example 0

time_of(Input)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true11996-03-21T00:00:00.000000000
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true21996-04-21T00:00:00.000000000
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false31996-05-21T00:00:00.000000000
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true41996-06-21T00:00:00.000000000
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false51996-07-21T00:00:00.000000000
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true61996-08-21T00:00:00.000000000

upper


πŸ§ͺ

upper(s: string) -> string

Converts the string to upper case.

  • string

upper Example 0

Input.value | upper()

Input

timesubsortkeyvalue
10000BenHello World
20000Ryan
30000RyanHi Earth
40000BenHello
50000Ben
60000Ryanhi

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000BenHello WorldHELLO WORLD
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000RyanHi EarthHI EARTH
1970-01-01T00:00:00.0000040000BenHelloHELLO
1970-01-01T00:00:00.0000050000Ben
1970-01-01T00:00:00.0000060000RyanhiHI

variance


πŸ§ͺ

variance(input: number, window: window = null) -> f64

Computes the sample variance of values across the input.

πŸ“˜

This uses the sample variance formula, which divides by the number of values minus 1, rather than the population variance which divides by the number of values.

  • aggregation * math

variance Example 0

variance(Input.value)

Input

timesubsortkeyvalue
10000Ben50.7
20000Ryan
30000Ryan67.2
40000Ben1.2
50000Ben
60000Ryan2.3

Output

timesubsortkeyvalueresult
1970-01-01T00:00:00.0000010000Ben50.7
1970-01-01T00:00:00.0000020000Ryan
1970-01-01T00:00:00.0000030000Ryan67.2
1970-01-01T00:00:00.0000040000Ben1.2612.5625000000001
1970-01-01T00:00:00.0000050000Ben612.5625000000001
1970-01-01T00:00:00.0000060000Ryan2.31053.0025000000003

when


πŸ§ͺ

when(condition: bool, value: any) -> any

Produces the current value when the condition evaluates to true.

πŸ“˜

If the value is continuous (eg., the result of an aggregation) returns the latest result of the aggregation. If the value is not continuous (eg., taken directly from events) returns the current value if it exists, and null otherwise.

  • time

when Example 0

Input.n | when(Input.condition)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true11
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true22
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true44
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true66

year


πŸ§ͺ

year(time: timestamp_ns) -> i32

Return the year of the given timestamp.

  • time

year Example 0

year(Input.date)

Input

timesubsortkeydateconditionn
1996-03-21T00:00:00-00:000Ben1996-08-19T00:00:00-00:00true1
1996-04-21T00:00:00-00:000Ryan1996-07-20T00:00:00-00:00true2
1996-05-21T00:00:00-00:000Ryan1996-07-22T00:00:00-00:00false3
1996-06-21T00:00:00-00:000Ryan1996-06-22T00:00:00-00:00true4
1996-07-21T00:00:00-00:000Ben1996-07-22T00:00:00-00:00false5
1996-08-21T00:00:00-00:000Ben1996-08-22T00:00:00-00:00true6

Output

timesubsortkeydateconditionnresult
1996-03-21T00:00:00.0000000000Ben1996-08-19T00:00:00-00:00true11996
1996-04-21T00:00:00.0000000000Ryan1996-07-20T00:00:00-00:00true21996
1996-05-21T00:00:00.0000000000Ryan1996-07-22T00:00:00-00:00false31996
1996-06-21T00:00:00.0000000000Ryan1996-06-22T00:00:00-00:00true41996
1996-07-21T00:00:00.0000000000Ben1996-07-22T00:00:00-00:00false51996
1996-08-21T00:00:00.0000000000Ben1996-08-22T00:00:00-00:00true61996

yearly


πŸ§ͺ

yearly() -> bool

A periodic function that produces a boolean value that is true at the start of each calendar year (UTC).

  • window

yearly Example 0

sum(Input.n, since(yearly()))

Input

timesubsortkeyn
1996-12-19T16:00:00-00:000Ben2
1996-12-19T16:00:00-00:000Ryan3
1997-12-20T16:00:00-00:000Ben6
1997-12-20T16:01:00-00:000Ben9
1997-12-21T16:00:00-00:000Ryan8
1998-12-21T16:00:00-00:000Ben1

Output

timesubsortkeynresult
1996-12-19T16:00:00.0000000000Ben22
1996-12-19T16:00:00.0000000000Ryan33
1997-01-01T00:00:00.00000000018446744073709551615Ben2
1997-01-01T00:00:00.00000000018446744073709551615Ryan3
1997-12-20T16:00:00.0000000000Ben66
1997-12-20T16:01:00.0000000000Ben915
1997-12-21T16:00:00.0000000000Ryan88
1998-01-01T00:00:00.00000000018446744073709551615Ben15
1998-01-01T00:00:00.00000000018446744073709551615Ryan8
1998-12-21T16:00:00.0000000000Ben11

zip_max


πŸ§ͺ

zip_max(a: ordered, b: ordered) -> ordered

Returns the maximum of two values.

πŸ“˜

Returns a if a > b, otherwise returns b. Specifically, if a or b is NaN b will be returned.

  • math

zip_max Example 0

zip_max(Input.a, Input.b)

Input

timesubsortkeyab
10000A5.71.2
10011A6.30.4
10012B3.7
10021A13.2

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000A5.71.25.7
1970-01-01T00:00:00.0000010011A6.30.46.3
1970-01-01T00:00:00.0000010012B3.7
1970-01-01T00:00:00.0000010021A13.2

zip_min


πŸ§ͺ

zip_min(a: ordered, b: ordered) -> ordered

Returns the minimum of two values.

πŸ“˜

Returns a if a < b, otherwise returns b. Specifically, if a or b is NaN b will be returned.

  • math

zip_min Example 0

zip_min(Input.a, Input.b)

Input

timesubsortkeyab
10000A5.71.2
10011A6.30.4
10012B3.7
10021A13.2

Output

timesubsortkeyabresult
1970-01-01T00:00:00.0000010000A5.71.21.2
1970-01-01T00:00:00.0000010011A6.30.40.4
1970-01-01T00:00:00.0000010012B3.7
1970-01-01T00:00:00.0000010021A13.2

generated on 2022-01-21 18:55:11Z