Sets the data type of the specified column or columns. The column data is validated against the new data type, which can change the results of column profiling.

Type is specified as a string literal or comma-separated set of literals. For more information on valid string literals, see Valid Data Type Strings .

Tips:

Tip: You can use the settype transform to override the data type inferred for a column. However, if a new transformation step is added, the column data type is re-inferred, which may override your specific typing. You should consider applying setttype transforms as late as possible in your recipes.

You can also specify any custom data types that have been defined.

Single-column example:

settype col: Score type: 'Integer'

Output: Changes the data type for the Score column to Integer.

Multi-column example:

settype col: Score,studentId type: 'Integer'

Output: Changes the data type for the Score and studentId columns to Integer.

settype col:col1,col2 type:'string_literal'

TokenRequired?Data TypeDescription
settypeYtransformName of the transform
colYstringComma-separated list of columns to which to apply the specified type.
typeYstringString literal identifying the data type to apply to the column(s). See Valid Data Type Strings.

col

Identifies the column(s) to which to apply the transform. You can specify one or more columns.

Required?Data Type
YesComma-separated strings (column name or names)

type

settype col: zips type:'Zipcode'

Output: Changes the data type of the zips column to Zip Code data type. All values are validated as U.S. Zip code.

Required?Data Type
YesString value

Example - Simple settype with date values

Source:

Here is a list of activities listed by date. Note the variation in date values, including what is clearly an invalid date. Here is the source data:

myDate, myAction
4/4/2016,Woke up at 6:30
4-4-2016,Got ready
9-9-9999,Drove kids to school
4-4-2016, Commuted to work


Transform:

When this data is imported into the Transformer page, there are couple of immediate issues: no column headings and blank rows at the bottom. These two transforms fix that:

header

delete row: ISMISSING([myDate])

For the invalid date, you can infer from the rows around it that it should be from the same date. You can make the following change to fix it:

replace col: myDate on: `9-9-9999` with: '4-4-2016' global: true

Now that the dates look fairly consistent, you can set the data type of the column to a matching Datetime format:

settype col: myDate type: 'Datetime','mm-dd-yy','mm*dd*yyyy'

Note the syntax above for specifying Datetime types. In addition to the Datetime keyword, you must specify the format type, followed by the variation of that format.

Tip: A set of supported formats and variations for Datetime are available through the column data type selector. When you select your desired Datetime format, the setttype transform is added to your recipe.

Results:

myDatemyAction
4/4/2016Woke up at 6:30
4-4-2016Got ready
4-4-2016Drove kids to school
4-4-2016Commuted to work

Example - Use merge and settype to clean up numeric data that should be treated as other data types