Shape · Columns
Cast Types
Changes a column's type, such as text to number or text to date. You choose what happens to a value that won't convert: stop the run, or make it blank with or without a warning.
Also known as: Data type, change type
How it works
Click Add rule and pick a column and a target type: VARCHAR, BIGINT (64-bit integer), INTEGER (32-bit integer), DOUBLE, BOOLEAN, DATE, TIMESTAMP, TIME or DECIMAL, which also takes a precision and scale; DOUBLE has an optional round dp. The third control says what happens to a value that will not convert: Error stops the run, Warn (the default) sets it to null and badges the node with how many values it lost, Ignore sets it to null without a badge. A null stays null. Use BIGINT for whole numbers; INTEGER nulls anything beyond ±2147483647.
Inputs and outputs
Inputs
data— Table
Outputs
data— Table
Settings
The Attributes panel of Cast Types, as in the app: the controls work, but nothing runs — there is no data behind it.
The same settings, as the Assistant writes them
{
rules: [{ column: string, targetType: "VARCHAR"|"BIGINT"|"INTEGER"|"DOUBLE"|"BOOLEAN"|"DATE"|"TIMESTAMP"|"TIME"|"DECIMAL", precision?: number, scale?: number, round?: number, onError?: "null"|"error"|"ignore" }]
}BIGINT is the 64-bit integer: use it to make a column an integer. INTEGER is 32-bit and nulls any value beyond ±2147483647
Example
A CSV reader detected quantity as text because one row holds n/a. Add a rule quantity to BIGINT (64-bit integer) with Warn: every number converts, the n/a row becomes null and the node badge reports 1 value could not be cast. For money, cast price to DECIMAL with precision 12 and scale 2.
| quantity (text) | quantity (BIGINT) |
|---|---|
| 42 | 42 |
| n/a | NULL |
| 7 | 7 |