Computed Fields
Computed fields allow you to extend the source table and stage table with additional settings.
For example, you use the computed fields to set the partial full load field when set partial full load mode in CSV Downloader or SQL Downloader. For more information, see ‘Set partial full load mode for the entities’ in CSV Downloader or SQL Downloader, correspondingly.
Structure and Parameters
The ‘computed_field’ section contains an array of parameters.
"computed_fields": [
{
"name": "custom_field_name",
"type": "field_data_type",
"table_type": ["src|stg"],
"function": "function_name",
"definition": "function_definition",
"key": "true|false", // optional
"position": "last|first", // optional
"encoding": "encoding_type" // optional
}
]
Name | Type | Mandatory? | Default | Description |
---|---|---|---|---|
name | string | yes | n/a | The name of the custom field in the database |
type | string | yes | n/a | The type of the custom field Possible values:
|
table_type | array | yes | n/a | The type of the table (stage or source) where the custom field will be created Possible values:
|
function | string | yes | n/a | The function that will be used for filling in the custom field Possible values for the source table (
Possible values for the stage table (
|
definition | string | see 'Description' | n/a | (Only when 'function' is set to 'custom_function') The definition of the function |
key | Boolean | no | false | (Only when 'function' is set to 'runtime_metadata|value' or 'value|value_name') Specifies whether the custom field will be used as part of the primary key
|
position | string | no | last | (Only when 'key' is set to 'true') Specifies whether the custom field should be on the first or the last position in the primary key. Possible values:
TIP: If you are using the computed fields for setting partial full load mode (see 'Set partial full load mode for the entities' in CSV Downloader or SQL Downloader), use the 'position' parameter together with the 'encoding' parameter (see below in this table) for better performance. Set the 'position' parameter to 'first', and set the 'encoding' parameter to 'RLE'. |
encoding | string | no | AUTO | The encoding type of fields For information about available options, see Encoding Types in Vertica. TIP: If you are using the computed fields for setting partial full load mode (see 'Set partial full load mode for the entities' in CSV Downloader or SQL Downloader), use the 'encoding' parameter together with the 'position' parameter (see above in this table) for better performance. Set the 'encoding' parameter to 'RLE', and set the 'position' parameter to 'first'. |
Examples
"computed_fields": [
{
"name": "field_extract",
"type": "string-255",
"function": "custom_function",
"table_type": ["src"],
"definition": "LEFT(\"field1\",5)"
}
]
Location
You can place the ‘computed_fileds’ section in either of the following locations in the configuration file:
In the ‘custom’ section for a specific entity (if you want to apply it only to this entity):
"entities": { "table_1_name": { "global": { "custom": { "hub": ["column_1_name","column_2_name","column_3_name"], "partial_full_load_field": "custom_field_name", // optional "computed_fields": [ { "name": "custom_field_name", "type": "field_data_type", "table_type": ["src|stg"], "function": "function_name", "definition": "function_definition", "key": "true|false", // optional "position": "last|first", // optional "encoding": "encoding_type" // optional } ] } } } }
In the ‘ads_storage’ section (if you want to apply it to all processed entities):
"ads_storage": { "instance_id": "data_warehouse_instance_id", "username": "dw_email@address.com", "options": {}, "computed_fields": [ { "name": "custom_field_name", "type": "field_data_type", "table_type": ["src|stg"], "function": "function_name", "definition": "function_definition", "key": "true|false", // optional "position": "last|first", // optional "encoding": "encoding_type" // optional } ] }