make_col

Aliases: colmake (deprecated).

make_col [columnbinding: expression]+

Evaluates one or more name:expression bindings per row, inserting new columns or replacing existing columns of the same name while keeping the input dataset kind.

Bindings are processed left to right. Column references inside expressions are resolved against the input row type for that stage, so a later binding can use an input column name that also appears as the left-hand side of an earlier binding (for example, swap-style patterns such as a:d, b:a where a, b, and d are all input columns). A binding cannot refer to a name that exists only as the output of an earlier binding in the same make_col; build that in a following pipeline stage instead. Window functions are allowed in expressions.

Column order

New columns are ordered immediately after the rightmost referenced input column; bindings that share the same source column stay grouped in source order.

Primary keys and time columns

On resource inputs, overwriting a primary-key column is an error unless the binding is effectively a rename from another existing column. On non-resource inputs, overwriting a primary-key column clears primary-key metadata on the output instead of erroring. The designated valid-from and valid-to columns cannot be replaced with a different expression; rebinding a time column to itself is allowed.

Keys, links, and interfaces

Overwriting or renaming columns can update or remove candidate keys, foreign keys, grouping keys, and interface bindings when those structures referenced the affected columns.

For selecting or dropping columns without expressions, prefer pick_col, drop_col, or rename_col. For pulling fields from text with regex capture groups, see extract_regex.

Categories

Accelerable

make_col is always accelerable if the input is accelerable. A dataset that only uses accelerable verbs can be accelerated, making queries on the dataset respond faster.

Examples

make_col idx:month_number, title:string(month_name)

Add two derived columns with basic name:expression bindings, copying a numeric field as int64 and a text field as string in one stage.

make_col second_half:bool(month_number > 6), label:string(month_name)

Combine a boolean expression and a string cast in one make_col stage to show how later bindings can depend on input columns and how types are carried into new fields.

make_col name_copy:month_name, num_copy:month_number

Bind two new columns from different existing columns to illustrate how each new column is placed after the rightmost source column it references, preserving readable column order.

make_col step:month_number
make_col doubled:int64(step * 2)
make_col triple:int64(doubled + step)

Use successive make_col stages so each new expression only references column names that already exist on the row going into that stage, which is how the compiler resolves paths during type checking.