Skip to main content

"alterIntegrationTable"

Abstract

alterIntegrationTable alters table settings that are safe to modify.

The "alterIntegrationTable" action alters table settings that are safe to modify.

Things to know

  • 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.

    Tip

    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.

  • 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

Rename table request example

{
  "api": "hub",
  "apiVersion": "1.0",
  "requestId": "5",
  "authToken": "anAuthTokenProvidedbyServer",
  "action": "alterIntegrationTable",
  "params": 
  {
    "databaseName": "faircom",
    "tableName": "test2",
    "newTableName": "test3"
  }
}
{
  "api": "hub",
  "apiVersion": "1.0",
  "requestId": "1",
  "authToken": "anAuthTokenProvidedbyServer",
  "action": "alterIntegrationTable",
  "params": 
  {
    "databaseName": "faircom",
    "tableName": "test2",
    "retentionPeriod": 2,
    "retentionUnit": "month",
    "metadata": {
      "tags": ["test", "deleteme"] 
    }
  }
}
{
  "api": "hub",
  "apiVersion": "1.0",
  "requestId": "2",
  "authToken": "anAuthTokenProvidedbyServer",
  "action": "alterIntegrationTable",
  "params": {
    "databaseName": "faircom",
    "tableName": "test2",
    "alterFields": [
      {
        "name": "t10",
        "type": "VARCHAR",
        "length": 65500,
        "nullable": true
      }
    ],
    "retentionPeriod": 45,
    "retentionUnit": "day"
  }
}
{
  "api": "hub",
  "apiVersion": "1.0",
  "requestId": "3",
  "authToken": "anAuthTokenProvidedbyServer",
  "action": "alterIntegrationTable",
  "params": 
  {
    "databaseName": "faircom",
    "tableName": "test2",
    "addFields": 
    [
      {
        "name": "new_field1",
        "type": "LVARCHAR",
        "nullable": true
      },
      {
        "name": "new_field2",
        "type": "TIMESTAMP",
        "nullable": true
      }
    ]
  }
}
{
  "api": "hub",
  "apiVersion": "1.0",
  "requestId": "4",
  "authToken": "anAuthTokenProvidedbyServer",
  "action": "alterIntegrationTable",
  "params": 
  {
    "databaseName": "faircom",
    "tableName": "test2",
    "deleteFields": 
    [
      "new_field1", "new_field2"
    ]
  }
}
{
  "api": "hub",
  "apiVersion": "1.0",
  "requestId": "5",
  "authToken": "anAuthTokenProvidedbyServer",
  "action": "alterIntegrationTable",
  "params": 
  {
    "databaseName": "faircom",
    "tableName": "test2",
    "transformName": "firstCreateMe"
  }
}

Response examples

{
    "authToken": "anAuthTokenProvidedbyServer",
    "result": {},
    "requestId": "1",
    "errorCode": 0,
    "errorMessage": ""
}
{
    "authToken": "anAuthTokenProvidedbyServer",
    "result": {},
    "requestId": "5",
    "errorCode": 100,
    "errorMessage": "Not able to find integration table by name [test3/admin/faircom]."
}
{
    "authToken": "anAuthTokenProvidedbyServer",
    "result": {},
    "requestId": "5",
    "errorCode": 100,
    "errorMessage": "Transform pipeline [firstCreateMe] was not found."
}

"params"

The "params" property is an object that contains an action's parameters. Each action defines its own required and optional properties.

Property summary

Table 1. "params" property summaries

Property

Description

Default

Type

Limits (inclusive)

"alterFields"

defines how to alter a field in a table

[]

array of objects

"databaseName"

specifies the name of a database

Defaults to the "defaultDatabaseName" value that is set during "createSession". If no default is set during "createSession", then "faircom" is used.

string

Minimum length: 1
Maximum length: 64

"retentionPolicy"

controls how messages are persisted

"autoPurge"

string

"autoPurge"
"neverPurge"
"doNotPersist"

"retentionPeriod"

sets the number of retention units, which controls how long data is retained – see "retentionUnit"

4

integer

1 - 100

"retentionUnit"

purges expired messages each time this unit cycles – see "retentionPeriod"

"week"

string

"minute"
"hour"
"day"
"week"
"month"
"year"

"tableName"

specifies the name of a table

Required - No default value

string

Minimum length: 1
Maximum length 64

"transformName"

contains the name of a transform process

Required - No default value

string

Minimum length: 1
Maximum length: 64


The "databaseName" property is an optional string that specifies the database that contains the tables. It defaults to the database name supplied at login.

Note

In the API Explorer, "defaultDatabaseName" is set to "ctreeSQL" in the "createSession" action that happens at login.

Things to know:
  • A zero-length "databaseName" is invalid.

  • Its limits are from 0 to 64 bytes.

  • If the "databaseName" property is omitted or set to null, the server will use the default database name specified at login.

  • If no default database is specified during "createSession", "defaultDatabaseName" will be set to the "defaultDatabaseName" value that is specified in the services.json file.

The "retentionPolicy" property controls how messages are persisted. This property is optional.

If not specified, the default found in the services.json file is used. Initially, it is "autoPurge".

retentionPolicy values:
  • "autoPurge"

    This is the default. It is automatically applied when a new topic is created. It is preferred because it allows FairCom's servers to automatically remove messages that are older than the retention time. This helps ensure message data does not consume all storage space. It also minimizes storage costs and speeds up data access.

  • "neverPurge"

    This stores messages on disk and never removes them. This is useful when you need the entire history of the message stream. If message velocity is high, this can consume all storage space and cause an outage.

  • "doNotPersist"

    This stores messages only in RAM, where they are transmitted more quickly. Undelivered messages are lost when FairCom's servers stop and restart. No transforms can be applied to the payload. Message data cannot be bridged across protocols.

Important

Changing the "retentionPolicy" property value to "doNotPersist" removes all existing message history for the topic because it changes how messages are stored on disk.

The "retentionPeriod" property specifies how many units of data to retain. It must be an integer value from 1 to 100. It refers to the unit of time specified by the "retentionUnit" property — for example, if "retentionPeriod" is 14 and "retentionUnit" is "day", then message data is retained for 14 days. This property is optional.

If not specified, the default found in the services.json file is used. Initially, it is 4 (weeks).

Automatically purging data is important to ensure that retained data does not consume all storage and shut down the computer. The default value of 4 weeks allows FairCom's servers to store 1 TB of messages when 200 topics send one 2K message per second.

Note

  • If the value is not an integer from 1 to 100, FairCom's servers set it to the default value.

  • Smaller numbers improve SQL performance.

Things to know:
  • Each time the "retentionPeriod" cycles, FairCom's servers automatically and efficiently delete expired data.

  • FairCom's servers only use the "retentionPeriod" property when the "retentionPolicy" is "autoPurge".

  • The "retentionPeriod" can be changed to retain fewer or more messages. Changing it does not necessarily destroy existing data, but data may expire more quickly or be retained longer.

  • The "retentionPeriod" and "retentionUnit" properties control data granularity as well as the retention time.  In other words, "retentionPeriod" defines how many sets of data are stored, and "retentionUnit" defines how often data is purged.

    For example, if "rententionPeriod" is set to 14 , the server stores 14 sets of data. At the beginning of the 15th cycle, the server automatically purges the oldest set of data. If "retentionUnit" is set to day, then data will be purged daily. If set to "week", then data will be purged weekly.

  • The current calendar date affects purging.

    FairCom's servers automatically purge all retained data that has expired. This is noticeable when FairCom's servers come online after having been offline for a long time. When a server comes back online, it automatically purges all expired data.

    For example, if a FairCom server is offline for four weeks when it comes online, it will completely purge all retained data that has a retention time of less than 4 weeks.

Each time this unit cycles, FairCom purges expired messages. For example, if you want a week's worth of messages to be purged once a week, set "retentionUnit" to "week" . This property is optional.

If not specified, the default found in the services.json file is used. Initially, it is "week"

Things to know:
  • This property is used in concert with "retentionPeriod" to determine retention time.

  • "retentionUnit" values:

    • "minute"

    • "hour"

    • "day"

    • "week"

    • "month"

    • "year"

    • "forever"

Note

  • For best performance, set the "retentionUnit" to a value that keeps "retentionPeriod" between 5 and 30

  • When the "retentionUnit" is set to "forever"  the messages will never be purged.

  • FairCom MQ only uses the "retentionUnit" property when the "retentionPolicy" is "autoPurge".

The "tableName" property is an optional string that contains the name of an integration table or MQTT topic that holds the topic's messages. It defaults to an empty string.

Things to know:
  • You can use a topic name for an MQTT table because FairCom automatically generates a table name for each topic.

  • A "tableName" cannot begin with a number.

  • It refers to the name of the integration table that stores a topic’s messages and is used to rename that table or assign a new topic to an existing integration table.

  • MQTT automatically creates an integration table for each new topic it receives. Thus, when a message is sent to a topic, FairCom Edge automatically creates a table to hold it.

  • 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 "tableName" property of the "configureTopic" action to rename an integration table.

  • The "alterIntegrationTable" action can also be used to rename an integration table, but it is less convenient because you must know the original name of the integration table.

The "transformName" property is a required string that contains the unique name of a transform process, which consists of one or more transform steps.

Things to know:
  • A transform is a process that works like a pipeline where the output of one transformation can become the input for another transformation.

  • The following actions use the "transformName" property to assign a transform to an integration table:

    • "configureTopic"

    • "createInput"

    • "alterInput"

    • "alterIntegrationTable"