Skip to main content
Version: v1.15.0

typename

Function

typename look up and return a named type

Synopsis

typename(name: string) -> type

Description

The typename function returns the type of the named type given by name if it exists. Otherwise, error("missing") is returned.

Examples

Return a simple named type with a string constant argument:

echo  '80(port=int16)' | zq -z 'yield typename("port")' -

=>

<port=int16>

Return a named type using an expression:

echo  '{name:"port",p:80(port=int16)}' | zq -z 'yield typename(name)' -

=>

<port=int16>

The result is error("missing") if the type name does not exist:

echo  '80' | zq -z 'yield typename("port")' -

=>

error("missing")