

# Basic column recipe steps


Use these basic column recipe actions to perform simple transformations on your data.

**Topics**
+ [

# CHANGE\$1DATA\$1TYPE
](recipe-actions.CHANGE_DATA_TYPE.md)
+ [

# DELETE
](recipe-actions.DELETE.md)
+ [

# DUPLICATE
](recipe-actions.DUPLICATE.md)
+ [

# JSON\$1TO\$1STRUCTS
](recipe-actions.JSON_TO_STRUCTS.md)
+ [

# MOVE\$1AFTER
](recipe-actions.MOVE_AFTER.md)
+ [

# MOVE\$1BEFORE
](recipe-actions.MOVE_BEFORE.md)
+ [

# MOVE\$1TO\$1END
](recipe-actions.MOVE_TO_END.md)
+ [

# MOVE\$1TO\$1INDEX
](recipe-actions.MOVE_TO_INDEX.md)
+ [

# MOVE\$1TO\$1START
](recipe-actions.MOVE_TO_START.md)
+ [

# RENAME
](recipe-actions.RENAME.md)
+ [

# SORT
](recipe-actions.SORT.md)
+ [

# TO\$1BOOLEAN\$1COLUMN
](recipe-actions.TO_BOOLEAN_COLUMN.md)
+ [

# TO\$1DOUBLE\$1COLUMN
](recipe-actions.TO_DOUBLE_COLUMN.md)
+ [

# TO\$1NUMBER\$1COLUMN
](recipe-actions.TO_NUMBER_COLUMN.md)
+ [

# TO\$1STRING\$1COLUMN
](recipe-actions.TO_STRING_COLUMN.md)

# CHANGE\$1DATA\$1TYPE


Changes the data type of an existing column.

If a column value can’t be converted to the new type, it will be replaced with NULL. This can happen when a string column is converted to an integer column. For example, string "123" will become integer 123, but string "ABC" cannot become a number, so it will be replaced with a NULL value.

**Parameters**
+ `sourceColumn` – The name of an existing column.
+ `columnDataType` – New type of the column. The following data types are supported:
  + **byte: **1-byte signed integer numbers. The range of numbers is from -128 to 127.
  + **short: **2-byte signed integer numbers. The range of numbers is from -32768 to 32767.
  + **int: **4-byte signed integer numbers. The range of numbers is from -2147483648 to 2147483647.
  + **long: **8-byte signed integer numbers. The range of numbers is from -9223372036854775808 to 9223372036854775807.
  + **float: **4-byte single-precision floating point numbers.
  + **double: **8-byte double-precision floating point numbers.
  + **decimal: **Signed decimal numbers with up to 38 digits total and 18 digits after the decimal point.
  + **string: **Character string values.
  + **boolean: **Boolean type has one of two possible values: `true` and `false` or `yes` and `no`.
  + **timestamp: **Values comprising fields year, month, day, hour, minute, and second.
  + **date: **Values comprising fields year, month and day.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "CHANGE_DATA_TYPE",
        "Parameters": {
            "sourceColumn": "columnName",
            "columnDataType": "boolean"
        }
    } 
 }
```

# DELETE


Removes a column from the dataset.

**Parameters**
+ `sourceColumn` – The name of an existing column.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "DELETE",
        "Parameters": {
            "sourceColumn": "extra_data"
        }
    }
}
```

# DUPLICATE


Creates a new column with the different name, but with all of the same data. Both the old and new columns are retained in the dataset.

**Parameters**
+ `sourceColumn` – The name of an existing column.
+ `targetColumn` – A name for the duplicate column.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "DUPLICATE",
        "Parameters": {
            "sourceColumn": "last_name",
            "targetColumn": "copy_of_last_name"
        }
    }
}
```

# JSON\$1TO\$1STRUCTS


Converts a JSON string to statically typed structs. During conversion, it detects the schema of every JSON object and merges them in order to get the most generic schema to represent the entire JSON string. The “unnestLevel” parameter specifies how many levels of JSON objects to convert to structs.

**Parameters**
+ `sourceColumns` – A list of source columns.
+ `regexColumnSelector –` A regular expression to select the columns.
+ `removeSourceColumn` – A Boolean value. If `true` then remove the source column; otherwise, keep it.
+ `unnestLevel` – The number of levels to unnest.
+ `conditionExpressions` – Condition expressions.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "JSON_TO_STRUCTS",
        "Parameters": {
            "sourceColumns": "[\"address\"]",
            "removeSourceColumn": "true",
            "unnestLevel": "2"
       }
    }
}
```

# MOVE\$1AFTER


Moves a column to the position immediately after another column.

**Parameters**
+ `sourceColumn` – The name of an existing column.
+ `targetColumn` – The name of another column. The column specified by `sourceColumn` will be moved immediately after the column specified by `targetColumn`.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "MOVE_AFTER",
        "Parameters": {
            "sourceColumn": "rating",
            "targetColumn": "height_cm"
        }
    }
}
```

# MOVE\$1BEFORE


Moves a column to the position immediately before another column.

**Parameters**
+ `sourceColumn` – The name of an existing column.
+ `targetColumn` – The name of another column. The column specified by `sourceColumn` will be moved immediately after the column specified by `targetColumn`.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "MOVE_BEFORE",
        "Parameters": {
            "sourceColumn": "height_cm",
            "targetColumn": "weight_kg"
        }
    }
}
```

# MOVE\$1TO\$1END


Moves a column to the end position (last column) in the dataset.

**Parameters**
+ `sourceColumn` – The name of an existing column.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "MOVE_TO_END",
        "Parameters": {
            "sourceColumn": "height_cm"
        }
    }
}
```

# MOVE\$1TO\$1INDEX


Moves a column to a position specified by a number.

**Parameters**
+ `sourceColumn` – The name of an existing column.
+ `targetIndex` – The new position for the column. Positions start with 0—so, for example, `1` refers to the second column, `2` refers to the third column, and so on.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "MOVE_TO_INDEX",
        "Parameters": {
            "sourceColumn": "nationality",
            "targetIndex": "5"
        }
    }
}
```

# MOVE\$1TO\$1START


Moves a column to the beginning position (first column) in the dataset.

**Parameters**
+ `sourceColumn` – The name of an existing column.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "MOVE_TO_START",
        "Parameters": {
            "sourceColumn": "first_name"
        }
    }
}
```

# RENAME


Creates a new column with the different name, but with all of the same data. The old column is then removed from the dataset.

**Parameters**
+ `sourceColumn` – The name of an existing column.
+ `targetColumn` – A new name for the column.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "RENAME",
        "Parameters": {
            "sourceColumn": "date_of_birth",
            "targetColumn": "birth_date"
        }
    }
}
```

# SORT


Sorts the data in one or more columns of a dataset in ascending, descending, or custom order.

**Parameters**
+ `expressions` – A string that contains one or more JSON-encoded strings representing sorting expressions.
  + `sourceColumn` – A string that contains the name of an existing column.
  + `ordering` – Ordering can be either ASCENDING or DESCENDING.
  + `nullsOrdering` – Nulls ordering can be either NULLS\$1TOP or NULLS\$1BOTTOM to place null or missing values at the beginning or at the bottom of the column. 
  + `customOrder` – A list of strings that defines a custom order for the string sorting. By default, strings are sorted alphabetically.
  + `isCustomOrderCaseSensitive` – Boolean. The default value is `false`.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "SORT",
        "Parameters": {
            "expressions": "[{\"sourceColumn\": \"A\", \"ordering\": \"ASCENDING\", \"nullsOrdering\": \"NULLS_TOP\"}]",
       }
    } 
 }
```


**Example of custom sort order**  
In the following example, the customOrder expression string has the format of a list of objects. Each object describes a sorting expression for one column.  
  

```
[
  {
    "sourceColumn": "A",
    "ordering": "ASCENDING",
    "nullsOrdering": "NULLS_TOP",
  },
  {
    "sourceColumn": "B",
    "ordering": "DESCENDING",
    "nullsOrdering": "NULLS_BOTTOM",
    "customOrder": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    "isCustomOrderCaseSensitive": false,
  }
]
```

# TO\$1BOOLEAN\$1COLUMN


Changes the data type of an existing column to BOOLEAN.

**Note**  
We recommend using CHANGE\$1DATA\$1TYPE recipe action rather than TO\$1BOOLEAN\$1COLUMN.

**Parameters**
+ `sourceColumn` – The name of an existing column.
+ `columnDataType` – A value that must be `boolean`.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "TO_BOOLEAN_COLUMN",
        "Parameters": {
            "columnDataType": "boolean",
            "sourceColumn": "is_present"
        }
    }
}
```

# TO\$1DOUBLE\$1COLUMN


Changes the data type of an existing column to DOUBLE.

**Note**  
We recommend using CHANGE\$1DATA\$1TYPE recipe action rather than TO\$1DOUBLE\$1COLUMN.

**Parameters**
+ `sourceColumn` – The name of an existing column.
+ `columnDataType` – A value that must be `number`.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "TO_DOUBLE_COLUMN",
        "Parameters": {
            "columnDataType": "number",
            "sourceColumn": "hourly_rate"
        }
    }
}
```

# TO\$1NUMBER\$1COLUMN


Changes the data type of an existing column to NUMBER.

**Note**  
We recommend using CHANGE\$1DATA\$1TYPE recipe action rather than TO\$1NUMBER\$1COLUMN.

**Parameters**
+ `sourceColumn` – The name of an existing column.
+ `columnDataType` – A value that must be `number`.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "TO_NUMBER_COLUMN",
        "Parameters": {
            "columnDataType": "number",
            "sourceColumn": "hours_worked"
        }
    }
}
```

# TO\$1STRING\$1COLUMN


Changes the data type of an existing column to STRING.

**Note**  
We recommend using CHANGE\$1DATA\$1TYPE recipe action rather than TO\$1STRING\$1COLUMN.

**Parameters**
+ `sourceColumn` – The name of an existing column.
+ `columnDataType` – A value that must be `string`.

**Example**  
  

```
{
    "RecipeAction": {
        "Operation": "TO_STRING_COLUMN",
        "Parameters": {
            "columnDataType": "string",
            "sourceColumn": "age"
        }
    }
}
```