schema
Applies a log schema to convert field names to display names and either select only the fields defined in the schema or reorder them.
Command properties
| Property | Description |
|---|---|
| Command type | Transforming |
| Required permission | None |
| License usage | N/A |
| Parallel execution | Not supported |
| Distributed execution | Runs on Data Node (mapper) |
Syntax
Options
overlay={t|f}- Whether to enable overlay mode. (Default:
f)
t: Reorders only the fields defined in the schema, and also outputs fields not defined in the schema.f: Selects and outputs only the fields defined in the schema.
locale=STR- Language to use for field display names. If not specified, the session locale is used.
Target
CODE- Code of the log schema to apply.
Error codes
Parsing errors
| Error code | Message | Description |
|---|---|---|
| 23600 | No schema parameter. | The schema code was not specified. |
| 23601 | No schema found for [code]. | No schema exists for the specified code. |
Runtime errors
N/A
Description
At execution time, the schema command is converted by the query planner into a combination of rename and fields (or order) commands. It renames each field defined in the schema to its display name.
When overlay=f (the default), only the fields defined in the schema are selected and output. When overlay=t, fields defined in the schema are sorted to the front while fields not defined in the schema are also included in the output.
If the locale option is specified, display names for that language are used. Otherwise, the current session locale setting is followed. If a display name for the requested language is unavailable, the default display name is used.
Examples
-
Apply a schema
table duration=1h firewall_logs | schema firewallApplies the
firewallschema to the data from thefirewall_logstable, converting field names to display names and outputting only the fields defined in the schema. -
Apply a schema in overlay mode
table duration=1h firewall_logs | schema overlay=t firewallSorts the fields defined in the
firewallschema to the front while also including fields not defined in the schema. -
Apply a schema with a specified locale
table duration=1h firewall_logs | schema locale=en firewallApplies the
firewallschema and outputs field display names in English.