Skip to main content
Version: v1.9.0

Functions


Functions appear in expression context and take Zed values as arguments and produce a value as a result. In addition to the built-in functions listed below, Zed also allows for the creation of user-defined functions.

A function-style syntax is also available for converting values to each of Zed's primitive types, e.g., uint8(), time(), etc. For details and examples, read about the cast function and how it is used in expressions.

  • abs - absolute value of a number
  • base64 - encode/decode base64 strings
  • bucket - quantize a time or duration value into buckets of equal widths
  • cast - coerce a value to a different type
  • ceil - ceiling of a number
  • cidr_match - test if IP is in a network
  • compare - return an int comparing two values
  • coalesce - return first value that is not null, a "missing" error, or a "quiet" error
  • crop - remove fields from a value that are missing in a specified type
  • error - wrap a value as an error
  • every - bucket ts using a duration
  • fields - return the flattened path names of a record
  • fill - add null values for missing record fields
  • flatten - transform a record into a flattened map
  • floor - floor of a number
  • grep - search strings inside of values
  • has - test existence of values
  • hex - encode/decode hexadecimal strings
  • has_error - test if a value has an error
  • is - test a value's type
  • is_error - test if a value is an error
  • join - concatenate array of strings with a separator
  • kind - return a value's type category
  • ksuid - encode/decode KSUID-style unique identifiers
  • len - the type-dependent length of a value
  • levenshtein Levenshtein distance
  • log - natural logarithm
  • lower - convert a string to lower case
  • missing - test for the "missing" error
  • nameof - the name of a named type
  • nest_dotted - transform fields in a record with dotted names to nested records
  • network_of - the network of an IP
  • now - the current time
  • order - reorder record fields
  • parse_uri - parse a string URI into a structured record
  • parse_zson - parse ZSON text into a Zed value
  • pow - exponential function of any base
  • quiet - quiet "missing" errors
  • regexp - perform a regular expression search on a string
  • regexp_replace - replace regular expression matches in a string
  • replace - replace one string for another
  • round - round a number
  • rune_len - length of a string in Unicode code points
  • shape - apply cast, fill, and order
  • split - slice a string into an array of strings
  • sqrt - square root of a number
  • trim - strip leading and trailing whitespace
  • typename - look up and return a named type
  • typeof - the type of a value
  • typeunder - the underlying type of a value
  • under - the underlying value
  • unflatten - transform a record with dotted names to a nested record
  • upper - convert a string to upper case