PantherFlow Functions
Use these functions in your PantherFlow query statements
PantherFlow is in open beta starting with Panther version 1.110, and is available to all customers. Please share any bug reports and feature requests with your Panther support team.
Aggregations
agg.avg()
agg.avg()
agg.avg(column: any) -> float
Returns the average of the values in the aggregation.
Example:
agg.count()
agg.count()
agg.count([column: any]) -> int
Returns the number of values in the aggregation.
Example:
agg.count_distinct()
agg.count_distinct()
agg.count_distinct(column: any) -> int
Returns the number of unique values in the aggregation.
Example:
agg.make_set()
agg.make_set()
agg.make_set(column: any) -> any
Returns a set of unique values from the column.
Example:
agg.max()
agg.max()
agg.max(column: any) -> float
Returns the maximum value in the aggregation.
Example:
agg.min()
agg.min()
agg.min(column: any) -> float
Returns the minimum value in the aggregation.
Example:
agg.stddev()
agg.stddev()
agg.stddev(column: [number]) -> float
Returns the sample standard deviation (square root of sample variance) of non-null values.
Example:
agg.sum()
agg.sum()
agg.sum(column: [any]) -> float
Returns the sum of the values in the aggregation.
Example:
agg.take_any()
agg.take_any()
agg.take_any(column: [any]) -> any
Returns any value from the aggregation.
Example:
Date/time
time.ago()
time.ago()
time.ago(span: timespan) -> timestamp
Returns the timestamp that is span
ago.
Example:
time.diff()
time.diff()
time.diff(unit: string, timestamp1: timestamp, timestamp2: timestamp) -> int
Calculates the difference between two timestamp expressions based on the date or time unitrequested. The function returns the result of subtracting timestamp1 from timestamp2 (i.e. timestamp2 - timestamp1).
Example:
time.now()
time.now()
time.now() -> timestamp
Returns the current timestamp.
Example:
time.parse_timespan()
time.parse_timespan()
time.parse_timespan(str: string) -> timespan
Returns the timespan representation of the duration string.
Example:
time.parse_timestamp()
time.parse_timestamp()
time.parse_timestamp(str: string) -> timestamp
Returns the timestamp representation of the timestamp string.
Example:
time.slice()
time.slice()
time.slice(time: timestamp, slice_length: int, slice_unit: string) -> timestamp
Returns the timestamp that time
resides in, given chunks of slice_unit
and slice_length
. For example, if slice_length
is 1 and slice_unit
is "hour", the time is truncated to the hour it belongs to. Slices are calculated relative to midnight January 1, 1970. slice_unit
can be:
year
,y
month
day
,d
hour
,h
minute
,m
second
,s
More values may be accepted, but are not guaranteed to be supported in future releases.
Example:
time.trunc()
time.trunc()
time.trunc(unit: string, timestamp: timestamp) -> timestamp
Returns the timestamp truncated to the specified unit. unit
can be:
year
,y
month
day
,d
hour
,h
minute
,m
second
,s
More values may be accepted, but are not guaranteed to be supported in future releases.
Example:
Strings
strings.cat()
strings.cat()
strings.cat(str: string, str: string, ... ) -> string
Concatenates strings.
Example:
strings.contains()
strings.contains()
strings.contains(str: any, substr: string) -> bool
Returns true if str
contains substr
. If str
is not a string, it is stringified first.
Example:
strings.ends_with()
strings.ends_with()
strings.ends_with(str: string, postfix: string) -> bool
Returns true if str
ends with postfix
.
Example:
strings.ilike()
strings.ilike()
strings.ilike(str: any, substr: string) -> bool
Returns true if str
contains substr
with SQL LIKE semantics ignoring case.
Example:
strings.join()
strings.join()
strings.join(elements: [string], sep: string) -> string
Returns elements
joined together with sep
between each element.
Example:
strings.len()
strings.len()
strings.len(str: any) -> int
Returns the length of str
. If str
is not a string, it is stringified first.
Example:
strings.like()
strings.like()
strings.like(str: any, substr: string) -> bool
Returns true if str
contains substr
with SQL LIKE semantics.
Example:
strings.lower()
strings.lower()
strings.lower(str: string) -> string
Returns str
converted to lower case.
Example:
strings.split()
strings.split()
strings.split(str: any, sep: string) -> [string]
Returns a list of substrings of str
separated by sep
.
Example:
strings.starts_with()
strings.starts_with()
strings.starts_with(str: string, prefix: string) -> bool
Returns true if str
starts with prefix
.
Example:
strings.upper()
strings.upper()
strings.upper(str: string) -> string
Returns str
converted to upper case.
Example:
Arrays
arrays.difference()
arrays.difference()
arrays.difference(arr: [any], excluded_arr: [any]) -> [any]
Returns an array that contains the elements from arr
that are not in excluded_arr
.
Example:
arrays.intersection()
arrays.intersection()
arrays.intersection(arr1: [any], arr2: [any]) -> [any]
Returns an array that contains only the elements that are in both arr1
and arr2
.
Example:
arrays.len()
arrays.len()
arrays.len(arr: [any]) -> int
Returns the length of arr
. If arr
is not an array it is jsonified first.
Example:
arrays.overlap()
arrays.overlap()
arrays.overlap(arr1: [any], arr2: [any]) -> bool
Returns true if arr1
and arr2
have any elements in common.
Example:
arrays.sort()
arrays.sort()
arrays.sort(arr: [any] [, sort_asc: bool] [, nulls_first: bool]) -> [any]
Returns an array that contains the elements of the input array arr
sorted in ascending or descending order. Defaults to ascending order. You can specify whether or not null elements are sorted before or after non-null elements. Defaults to nulls last in ascending order and null first in descending order.
Example:
arrays.union()
arrays.union()
arrays.union(arr1: [any], arr2: [any]) -> [any]
Returns an array that contains all deduplicated elements of arr1
and arr2
.
Example:
Math
math.round()
math.round()
math.round(value: number [, precision: int]) -> float
Returns the value rounded to the specified precision.
Example:
Control flow
case()
case()
case(condition1: bool, value1: any [, condition2: bool, value2: any, ... ] [, else: any]) -> any
Returns the first value for which the corresponding condition is true. If no condition is true, returns null.
Example:
Regular expressions
re.count()
re.count()
re.count(stringable: any, regex: string) -> int
Returns the number of times that regex
occurs in stringable
, or null
if any value is null
.
Example:
re.matches()
re.matches()
re.matches(stringable: any, regex: string) -> bool
Returns true if stringable
matches the regular expression regex
.
Example:
re.replace()
re.replace()
re.replace(stringable: any, regex: string, replacement: string) -> string
Returns stringable
with the specified pattern regex
(or all occurrences of the pattern) either removed or replaced by replacement
, or null
if any value is null
.
Example:
re.substr()
re.substr()
re.substr(stringable: any, regex: string) -> string
Returns the first substring that matches regex
within stringable
, or null
if any value is null
.
Example:
Snowflake
snowflake.func()
snowflake.func()
snowflake.func(func_name: string [, arg1: any, ... ]) -> any
Call any function in Snowflake. This function simply acts as a passthrough.
Example:
Data types
array()
array()
array(value1: any, value2: any, valueN: any, ... ) -> array
Returns an array with the given values.
Example:
object()
object()
object([key1: string, value1: any, ... ]) -> object
Returns an object with the given key-value pairs.
Example:
Other
coalesce()
coalesce()
coalesce(value1: any, value2: any, valueN: any, ... ) -> any
Returns the first non-null value in the list of arguments.
Example:
toscalar()
toscalar()
toscalar(query: tabular) -> any
Converts a query to a scalar value. If the row contains more than one value it randomly selects one of the values. If the query returns more than one row, it selects the first row.
Example:
Last updated