The "alterIntegrationTable" action alters table settings that are safe to modify.
- The settings that are safe to modify include:
- Renaming a table
- Adding fields
- Increasing field size
- Changing table retention policy
- Changing table metadata
- Changing a table's transformation pipeline
- As you refine your integration processes, you may want to rename an integration table to better label the data it holds.
- You can use the
"alterIntegrationTable"action with the"newTableName"property to rename an integration table. - You can also use the
"tableName"property of the"configureTopic"action to rename an integration table that is automatically created by an MQTT message. This is easy because you can rename the integration table using its MQTT topic.
- You can use the
- This action cannot shrink the size of fields because this destroys data.
- This action cannot rename fields because it breaks compatibility with bridges between services (integrations / configurations).
Request examples
Change retention policy of the "test1" integration table
Prerequisites: You must first create the "test1" integration table using the "createIntegrationTable" action.
{
"api": "hub",
"action": "alterIntegrationTable",
"params": {
"databaseName": "faircom",
"tableName": "test1",
"rebuildTable": true,
"retentionPolicy": "autoPurge",
"retentionPeriod": 7,
"retentionUnit": "day"
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Add user-defined fields to the "test1" integration table
Prerequisites: You must first create the "test1" integration table using the "createIntegrationTable" action.
{
"api": "hub",
"action": "alterIntegrationTable",
"params": {
"databaseName": "faircom",
"tableName": "test1",
"addFields": [
{
"name": "t1",
"type": "json"
},
{
"name": "t2",
"type": "varchar",
"length": 128,
"nullable": true
},
{
"name": "temperature",
"type": "double"
}
],
"rebuildTable": true
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Modify user-defined fields in the "test1" integration table
Prerequisites: You must first run the previous "alterIntegrationTable" example to add fields to the "test1" integration table.
{
"api": "hub",
"action": "alterIntegrationTable",
"params": {
"databaseName": "faircom",
"tableName": "test1",
"alterFields": [
{
"name": "t2",
"newName": "x1",
"type": "varchar",
"length": 150
}
],
"rebuildTable": true
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Delete user-defined fields in the "test1" integration table
Prerequisites: You must first modify the "test1" integration table using the previous "alterIntegrationTable" example.
{
"api": "hub",
"action": "alterIntegrationTable",
"params": {
"databaseName": "faircom",
"tableName": "test1",
"deleteFields": [
"x1"
],
"rebuildTable": true
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Modify the transform steps of the "test1" integration table
This example changes the transform steps assigned to the "test1" integration table.
{
"api": "hub",
"action": "alterIntegrationTable",
"params": {
"tableName": "test1",
"logTransformOverwrites": false,
"transformSteps": [
{
"transformStepMethod": "jsonToTableFields",
"mapOfPropertiesToFields": [
{
"recordPath": "source_payload.temperature",
"fieldName": "temperature"
}
]
},
{
"transformStepMethod": "tableFieldsToJson",
"mapOfPropertiesToFields": [
{
"fieldName": "temperature",
"recordPath": "t1.temperature"
}
]
}
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Change the metadata of the "test1" integration table
This example changes the metadata assigned to the "test1" integration table.
{
"api": "hub",
"action": "alterIntegrationTable",
"params": {
"databaseName": "faircom",
"tableName": "test1",
"metadata": {
"description": "This can be any description you want.",
"tags": [
"minimal",
"example",
"alterIntegrationTable"
],
"yourOwnProperties": "Minimal example, showing basic settings, metadata is very flexible, You can put anything here"
}
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Maximal
The example below shows all possible properties for each type of transform step.
{
"api": "hub",
"action": "testIntegrationTableTransformSteps",
"params": {
"databaseName": "faircom",
"ownerName": "admin",
"tableName": "myTable1",
"newTableName": "myTable2",
"logTransformOverwrites": true,
"disableTransformSteps": false,
"transformSteps": [
{
"transformStepName": "step1",
"transformStepMethod": "javascript",
"transformStepService": "v8TransformService",
"codeName": "convertFahrenheitToCelsius",
"ownerName": "admin",
"databaseName": "faircom"
},
{
"transformStepName": "step2",
"transformStepMethod": "tableFieldsToJson",
"mapOfPropertiesToFields": [
{
"fieldName": "my_source_field",
"recordPath": "my_output_field.myProperty",
"binaryFormat": "byteArray",
"numberFormat": "string",
"variantFormat": "json",
"dateFormat": "mm.dd.ccyy",
"timeFormat": "hh.mm.am/pm"
}
]
},
{
"transformStepName": "step3",
"transformStepMethod": "jsonToTableFields",
"mapOfPropertiesToFields": [
{
"recordPath": "my_source_field.myProperty",
"fieldName": "my_target_field",
"binaryFormat": "base64"
}
]
},
{
"transformStepName": "step4",
"transformStepMethod": "jsonToDifferentTableFields",
"targetTableName": "myTargetIntegrationTable",
"targetOwnerName": "admin",
"targetDatabaseName": "faircom",
"mapOfPropertiesToFields": [
{
"recordPath": "my_source_field.myProperty",
"fieldName": "my_target_field",
"binaryFormat": "hex"
}
]
}
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Response examples
Success
{
"result": {},
"requestId": "1",
"errorCode": 0,
"errorMessage": "",
"authToken": "replaceWithAuthTokenFromCreateSession"
}Wrong table name failure
{
"result": {},
"requestId": "5",
"errorCode": 100,
"errorMessage": "Not able to find integration table by name [test3/admin/faircom].",
"authToken": "replaceWithAuthTokenFromCreateSession"
}Wrong transform name failure
{
"result": {},
"requestId": "5",
"errorCode": 100,
"errorMessage": "Transform pipeline [firstCreateMe] was not found.",
"authToken": "replaceWithAuthTokenFromCreateSession"
}Changing retention policy, period, or unit without setting "rebuildTable" to true
{
"authToken": "replaceWithAuthTokenFromCreateSession",
"result": {},
"requestId": "00000001",
"debugInfo": {
"request": {
"authToken": "replaceWithAuthTokenFromCreateSession",
"api": "hub",
"action": "alterIntegrationTable",
"params": {
"databaseName": "faircom",
"tableName": "test1",
"rebuildTable": false,
"retentionPolicy": "doNotPersist",
"retentionPeriod": 1,
"retentionUnit": "day"
},
"requestId": "00000001",
"debug": "max"
}
},
"errorCode": 12006,
"errorMessage": "Before you can change the data retention policy, period, or unit, you must use "alterIntegrationTable" and add "rebuildTable": true to the request. WARNING: rebuilding a table disrupts data collection while it rewrites all records."
}
Properties
Request properties ("params")
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
addFields |
The "addFields": [
{
"autoValue": "none",
"name": "field1",
"type": "varchar",
"length": 50,
"scale": null,
"defaultValue": null,
"nullable": false,
"primaryKey":1
}
] |
Optional with default of []
|
array of objects |
|
|
addFields .length |
The It is required to set the length of the following fixed-length data types:
It is required to set the maximum length for the following variable-length data types:
It is optional to set the maximum length of the It is optional to set the maximum length of the
The
Request example Create a table that contains all field types that use the "fields": [
{
"name": "a",
"type": "char",
"length": 16
},
{
"name": "b",
"type": "varchar",
"length": 65500
} |
Optional with default of null
|
integer |
1 to 65500
|
|
addFields .name |
The The The
|
Required - No default value | string | 1 to 64 bytes |
|
addFields .nullable |
The "fields": [
{
"name": "company",
"type": "varchar",
"nullable": true
}
] |
Optional with default of true
|
Boolean |
|
|
addFields .type |
The
Request example "fields": [
{
"name": "j",
"type": "number"
}
] |
Required - No default value | string |
|
alterFields |
The In this example, the field named
Example "alterFields": [
{
"autoValue": "none",
"name": "field1",
"type": "varchar",
"newName": "address",
"newPosition": 5,
"length": 50,
"scale": null,
"defaultValue": null,
"nullable": false
}
] |
Optional with default of [{"name":""}]
|
array of objects |
"autoValue""name""type""newName""newPosition""length""scale""defaultValue""nullable"
|
|
alterFields .length |
The It is required to set the length of the following fixed-length data types:
It is required to set the maximum length for the following variable-length data types:
It is optional to set the maximum length of the It is optional to set the maximum length of the
The
Request example Create a table that contains all field types that use the "fields": [
{
"name": "a",
"type": "char",
"length": 16
},
{
"name": "b",
"type": "varchar",
"length": 65500
} |
Optional with default of null
|
integer |
1 to 65500
|
|
alterFields .name |
The The The
|
Required - No default value | string | 1 to 64 bytes |
|
alterFields .newName |
The
|
Optional with default of null
|
string | 1 to 64 bytes |
|
alterFields .type |
The
Request example "fields": [
{
"name": "j",
"type": "number"
}
] |
Required - No default value | string |
|
databaseName |
The You specify this property when you want to use a different database instead of the default. This property is useful because objects, such as tables and code packages, can have the same name in multiple databases. This feature allows you to create multiple environments in the same server and reuse the same JSON actions in each environment. For example, you can create It is an error to set If no default database is specified during |
Defaults to the session's "defaultDatabaseName" property |
string | 1 to 64 bytes |
deleteFields |
The
|
Optional with default of []
|
array | 1 to 64 bytes |
disableTransformSteps |
The |
Optional with default of false
|
Boolelan |
|
logTransformOverwrites |
The You typically set If multiple Additionally, non-JavaScript transform steps cannot overwrite protected fields or the You may create transform steps to take the value of one JSON property and store it in multiple fields as long as no previous transform steps have already put values in these fields. Conversely, you may take the value of one field and store it in multiple JSON properties.
|
Optional with default of false
|
Boolean |
|
metadata |
The "metadata" property contains user-defined properties that add keywords and tags about the code package. The server indexes this field with a full-text index so you can search for any word or phrase to find code packages. |
Optional with default of {}
|
object | 0 or more key/value pairs |
newTableName |
The See table name in System limits for the table naming requirements and limitations.
|
Optional with default of null
|
string | 1 to 64 bytes |
ownerName |
The You specify this property when you want to use a different account instead of the default. Your session's account must have the appropriate privileges to access the code package. This property is useful because objects, such as tables and code packages, can have the same name in the same database as long as different accounts own each object. This feature allows you to create duplicate objects for different users on the same server and reuse the same JSON actions on those objects. For example, an administrator can copy objects from a production environment to her account so she can troubleshoot an issue using the same JSON actions, JavaScript, and SQL code. It is an error to set If no default owner is specified during |
Optional with default of the session's "defaultOwnerName" property |
string | 1 to 64 bytes |
rebuildTable |
The
|
Optional with default of false
|
Boolean |
|
retentionPeriod |
The |
Optional with default of |
integer |
1 to 100
|
retentionPolicy |
The If not specified, the default found in the
retentionPolicy values:
|
Optional with default of |
string |
|
retentionUnit |
The If not specified, the default found in the
|
Optional with default of |
string |
|
tableName |
The See table name in System limits for the table naming requirements and limitations.
"params": {
"tableName": "ctreeTable"
} |
Required - No default value | string | 1 to 64 bytes |
transformSteps |
The "transformSteps" property specifies an array of transform objects. |
Required - No default value | array of objects |
0 or more objects containing 1 or more of the following properties:
|
|
transformSteps .codeName |
The It is an error to set The package's unique identifier is the combination of |
Required - No default value | string | 1 to 64 bytes |
|
transformSteps .databaseName |
The You specify this property when you want to use a different database instead of the default. This property is useful because objects, such as tables and code packages, can have the same name in multiple databases. This feature allows you to create multiple environments in the same server and reuse the same JSON actions in each environment. For example, you can create It is an error to set If no default database is specified during |
Defaults to the session's "defaultDatabaseName" property |
string | 1 to 64 bytes |
|
transformSteps .mapOfPropertiesToFields |
The
|
Optional with default of []
|
array |
|
|
transformSteps mapOfPropertiesToFields .binaryFormat |
The "binaryFormat" property designates the format of binary values embedded in JSON strings. For more details, see "binaryFormat". |
Optional with default of "hex"
|
string | One of the following: "base64", "hex", or "byteArray". |
|
transformSteps mapOfPropertiesToFields .dateFormat |
The The default value for The enumerated string defines how the server parses a date in a JSON string and how it writes a date into a JSON string. The following key explains the parts of each enumerated value:
UTC datetime format Coordinated Universal Time (UTC) is an industry-standard for dates and times that uses the ISO8601 datetime format:
|
Optional with default of "iso8601"
|
string enum |
|
|
transformSteps mapOfPropertiesToFields .fieldName |
The "fieldName" property specifies the name of a field in a table. |
Required - No default value | string | 1 to 64 bytes |
|
transformSteps mapOfPropertiesToFields .numberFormat |
The |
Optional with default of "number"
|
string |
|
|
transformSteps mapOfPropertiesToFields .recordPath |
The
|
Required - No default value | string | 0 to 256 bytes |
|
transformSteps mapOfPropertiesToFields .timeFormat |
The |
Optional with default of "hh.mm.am/pm"
|
string |
|
|
transformSteps mapOfPropertiesToFields .variantFormat |
The "variantFormat" property tells the server how to interpret the variant data included in a JSON Action request. For more details, see "variantFormat". |
Optional with default of "json"
|
string |
|
|
transformSteps .ownerName |
The You specify this property when you want to use a different account instead of the default. Your session's account must have the appropriate privileges to access the code package. This property is useful because objects, such as tables and code packages, can have the same name in the same database as long as different accounts own each object. This feature allows you to create duplicate objects for different users on the same server and reuse the same JSON actions on those objects. For example, an administrator can copy objects from a production environment to her account so she can troubleshoot an issue using the same JSON actions, JavaScript, and SQL code. It is an error to set If no default owner is specified during |
Optional with default of the session's "defaultOwnerName" property |
string | 1 to 64 bytes |
|
transformSteps .targetDatabaseName |
The
|
Optional with default of ""
|
string | 1 to 64 bytes |
|
transformSteps .targetOwnerName |
The |
Optional with default of ""
|
string | 1 to 64 bytes |
|
transformSteps .targetTableName |
The
|
Optional with default of ""
|
string | 1 to 64 bytes |
|
transformSteps .transformStepMethod |
The "transformStepMethod" property specifies the type of transform, such as the "javascript" transform method that runs JavaScript to change the table's data, or the "jsonToTableFields" transform method that extracts values from properties in a JSON field and stores them in other fields. For more details, see "transformStepMethod". |
Required - No default value | string enum |
|
|
transformSteps .transformStepName |
The |
Optional with default of ""
|
string | 1 to 64 bytes |
|
transformSteps .transformStepService |
The This property allows you to register your own transform libraries or use an older version of a FairCom library for backward compatibility. Transform services are defined in the
Example "transformServices" section in the services.json file. "transformServices": [
{
"serviceName": "v8TransformService",
"serviceLibrary": "v8transformservice.dll",
"enabled": true
}
],
|
Optional with default of ""
|
string | 1 to 64 bytes |