# Amazon Redshift Data Loading Reference

Learn how Stitch will load data from your integrations into Stitch’s Amazon Redshift destination.

In this guide, we’ll cover data loading scenarios involving:

* [The destinations this guide is applicable to](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#applicable-destination-types)

* [Primary key columns](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#primary-key-scenarios)

* [Replication keys and how data is loaded as a result](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#replication-key-scenarios)

* [Object identifiers in the destination, including naming limitations and transformations](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#object-name-scenarios)

* [Table creation and modification in the destination](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#table-name-scenarios)

* [Various data types, including how data is typed and structured in the destination](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#data-typing-scenarios)

* [Schema changes in the source or structural changes in the destination](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#schema-change-scenarios)

* [Modifications made to the destination, such as the application of workload/performance management features or user privilege changes](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#destination-change-scenarios)

## Applicable destination types

This guide is applicable to the all variations of the Amazon Redshift destination, including:

* [Amazon Redshift](https://help.qlik.com/en-US/stitch/destinations/amazon-redshift/reference)
* [Panoply](https://help.qlik.com/en-US/stitch/destinations/panoply/reference)

## Primary Key scenarios

Scenarios involving Primary Key columns.

A table without a Primary Key is replicated.

| **IF** | A table without a Primary Key is replicated. |
| --- | --- |
| **THEN** | <ul> <li><strong>Initial job</strong>: Table is created without Primary Key and no <code>NOT NULL</code> columns.</li> <li> <p><strong>Subsequent jobs</strong>: If using Key-based Incremental or Log-based Incremental Replication, data will be added to the table in an Append-Only fashion.</p> <p>If using Full Table Replication, the table will be overwritten in its entirety during each job.</p> </li></ul> |

A table with a single Primary Key is replicated.

| **IF** | A table with a single Primary Key is replicated. |
| --- | --- |
| **THEN** | <ul> <li> <p><strong>Initial job:</strong> Table is created without Primary Key and no <code>NOT NULL</code> columns. Primary Key info is stored as a comment on the table.</p> <p><strong>Note</strong>: Incorrectly altering or removing a table’s Primary Key comment will result in issues with replication.</p> </li> <li> <p><strong>Subsequent jobs:</strong> If using Key-based Incremental or Log-based Incremental Replication, data will be de-duped based on the Primary Key column and upserted into the table.</p> <p>If using Full Table Replication, the table will be overwritten in its entirety during each sync.</p> </li></ul> |

A table with multiple Primary Keys is replicated.

| **IF** | A table with multiple Primary Keys is replicated. |
| --- | --- |
| **THEN** | <ul> <li> <p><strong>Initial job</strong>: Table is created without Primary Key and no <code>NOT NULL</code> columns. Primary Key info is stored as a comment on the table.</p> <p><strong>Note</strong>: Incorrectly altering or removing a table’s Primary Key comment will result in issues with replication.</p> </li> <li> <p><strong>Subsequent jobs</strong>: If using Key-based Incremental or Log-based Incremental Replication, data will be de-duped based on the Primary Key columns and upserted into the table.</p> <p>If using Full Table Replication, the table will be overwritten in its entirety during each job.</p> </li></ul> |

The table's Primary Key(s) is/are changed.

| **IF** | The table’s Primary Key(s) is/are changed. |
| --- | --- |
| **THEN** | If using Key-based Incremental or Log-based Incremental Replication, data will be added to the table in an Append-Only fashion.<br><br>If using Full Table Replication, the table will be overwritten in its entirety during each job. |

You remove the Primary Key column(s) for a table in Amazon Redshift.

| **IF** | You remove the Primary Key column(s) for a table in Amazon Redshift. |
| --- | --- |
| **THEN** | Data will continue to be loaded into the table in an Append-Only fashion. |

[Back to top](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#)

## Replication Key scenarios

Scenarios involving Replication Keys and how data is loaded as a result.

A table using Key-based Incremental Replication is replicated where the Replication Key column contains NULL values.

| **IF** | A table using Key-based Incremental Replication is replicated where the Replication Key column contains `NULL` values. |
| --- | --- |
| **THEN** | <ul> <li><strong>During the initial job</strong>, the table will be created and all rows will be replicated.</li> <li><strong>During subsequent jobs</strong>, only rows with populated Replication Keys will be replicated and persisted to Amazon Redshift.</li></ul> |

[Back to top](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#)

## Object naming scenarios

Scenarios involving object identifiers in the destination, including naming limitations and transformations.

A table name contains more characters than allowed by Amazon Redshift.

| **IF** | A table name contains more characters than allowed by Amazon Redshift. |
| --- | --- |
| **THEN** | Amazon Redshift will reject all data for the table. |
| **AND** | The following error will display in the **Notifications** tab in Stitch:<br><br>```<br>Table name [TABLE] is too long for Amazon Redshift<br>```<br><br>`Table name [TABLE] is too long for Amazon Redshift`Table name [[TABLE] is too long for for Amazon Redshift<br><br><br>Rejected records will be logged in the `_sdc_rejected` table of the integration's schema. [Learn more](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table). |
| **FIX IT** | If possible, change the table name in the source to be less than Amazon Redshift’s character limit of 127 characters.<br><br><br>Use the [`_sdc_rejected` table](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table) to identify the root of the issue. |

A column name contains more characters than allowed by Amazon Redshift.

| **IF** | A column name contains more characters than allowed by Amazon Redshift. |
| --- | --- |
| **THEN** | Amazon Redshift will reject columns with names that exceed the column character limit. Other columns in the table will persist to Amazon Redshift. |
| **AND** | The following error will display in the **Notifications** tab in Stitch:<br><br>```<br>Column name [COLUMN] is too long for Amazon Redshift<br>```<br><br>`Column name [COLUMN] is too long for Amazon Redshift`Column name [[COLUMN] is too long for for Amazon Redshift<br><br><br>Rejected records will be logged in the `_sdc_rejected` table of the integration's schema. [Learn more](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table). |
| **FIX IT** | If possible, change the column name in the source to be less than Amazon Redshift’s character limit of 115 characters.<br><br><br>Use the [`_sdc_rejected` table](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table) to identify the root of the issue. |

Two columns are replicated that canonicalize to the same name.

| **IF** | Two columns are replicated that canonicalize to the same name. |
| --- | --- |
| **THEN** | For example: A table containing both `CustomerId` and `customerid` columns.<br><br>Amazon Redshift will reject the records and create a log for the rejected records in the `_sdc_rejected` table in that integration’s schema. |
| **AND** | The following error will display in the **Notifications** tab in Stitch:<br><br>```<br>Field collision on [COLUMN_NAME]<br>```<br><br>`Field collision on [COLUMN_NAME]`Field collision on [[COLUMN\_NAME]<br><br><br>Rejected records will be logged in the `_sdc_rejected` table of the integration's schema. [Learn more](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table). |
| **FIX IT** | If possible, re-name one of the columns in the source so that both column names will be unique when replicated to Amazon Redshift.<br><br><br>Use the [`_sdc_rejected` table](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table) to identify the root of the issue. |

A column is replicated that has a mixed-case name.

| **IF** | A column is replicated that has a mixed-case name. |
| --- | --- |
| **THEN** | Amazon Redshift will convert letters to lowercase. For example:<br><br><table> <thead> <tr> <th>Columns in Source</th> <th>Columns in Amazon Redshift</th> </tr> </thead>  <tr> <td><code>CuStOmErId</code></td> <td><code>customerid</code></td> </tr> <tr> <td><code>customerID</code></td> <td><code>customerid</code></td> </tr> </table> |

A column is replicated that has a name with spaces.

| **IF** | A column is replicated that has a name with spaces. |
| --- | --- |
| **THEN** | Amazon Redshift will maintain spaces. For example:<br><br><table> <thead> <tr> <th>Columns in Source</th> <th>Columns in Amazon Redshift</th> </tr> </thead>  <tr> <td><code>customer id</code></td> <td><code>customer id</code></td> </tr> <tr> <td><code>CUSTOMER ID</code></td> <td><code>customer id</code></td> </tr> </table> |

A column is replicated with a name that contains unsupported special characters.

| **IF** | A column is replicated with a name that contains unsupported special characters. |
| --- | --- |
| **THEN** | Amazon Redshift will remove all special characters with the exception of underscores and dollar signs. For example:<br><br><table> <thead> <tr> <th>Columns in Source</th> <th>&nbsp;</th> <th>Columns in Amazon Redshift</th> </tr> </thead>  <tr> <td><code>customer!id</code></td> <td>&nbsp;</td> <td><code>customerid</code></td> </tr> <tr> <td><code>!CUSTOMERID</code></td> <td>&nbsp;</td> <td><code>customerid</code></td> </tr> </table> |

A column is replicated with a name that begins with a non-letter.

| **IF** | A column is replicated with a name that begins with a non-letter. |
| --- | --- |
| **THEN** | This scenario is unremarkable to Amazon Redshift. |

[Back to top](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#)

## Table scenarios

Scenarios involving table creation and modification in the destination.

A table contains entirely NULL columns.

| **IF** | A table contains entirely `NULL` columns. |
| --- | --- |
| **THEN** | No table is created in Amazon Redshift. At least one column must have a non-`NULL` value for Stitch to create a table in Amazon Redshift. |

A table arrives with more columns than Amazon Redshift allows.

| **IF** | A table arrives with more columns than Amazon Redshift allows. |
| --- | --- |
| **THEN** | Amazon Redshift will reject all data for the table. |
| **AND** | The following error will display in the **Notifications** tab in Stitch:<br><br>```<br>ERROR: too many columns<br>```<br><br>`ERROR: too many columns`ERROR: too many columns<br><br><br>Rejected records will be logged in the `_sdc_rejected` table of the integration's schema. [Learn more](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table). |
| **FIX IT** | If possible, deselect some columns to allow Stitch to load data into Amazon Redshift for the table. Amazon Redshift has a limit of 1,600 columns per table.<br><br><br>Use the [`_sdc_rejected` table](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table) to identify the root of the issue. |

[Back to top](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#)

## Data typing scenarios

Scenarios involving various data types, including how data is typed and structured in the destination.

Stitch detects multiple data types for a single column.

| **IF** | Stitch detects multiple data types for a single column. |
| --- | --- |
| **THEN** | To accommodate data of varying types, Stitch will create multiple columns to ensure data is loaded with the correct type. In the destination, this will look like the column has been “split”.<br><br>For example: Stitch first detected that `order_confirmed` contained `BOOLEAN` data, but during a subsequent job, detected `STRING` values. To accommodate data of varying types, Stitch will:<br><br><ol> <li> <p>Re-name the original column. The new name will be the column name and a suffix indicating the data type Stitch detected first. In this example, the new column name would be <code>order_confirmed__bl</code>, <code>__bl</code> indicating <code>BOOLEAN</code>.</p> </li> <li> <p>Store data for the first-detected data type in the re-named column. In this example, all <code>BOOLEAN</code> data will be stored in <code>order_confirmed__bl</code>.</p> </li> <li> <p>Create additional columns to store other data types, one for each data type detected. Suffixes indicating the data type will be appended to the column names. In this example, <code>STRING</code> data will be stored in <code>order_confirmed__st</code>.</p> </li></ol> |

Data is replicated to Amazon Redshift that is nested, containing many top-level properties and potentially nested sub-properties.

| **IF** | Data is replicated to Amazon Redshift that is nested, containing many top-level properties and potentially nested sub-properties. |
| --- | --- |
| **THEN** | To ensure nested data can be loaded, Stitch will flatten objects and arrays into columns and subtables, respectively.<br><br>For more info and examples, refer to the [Handling nested data structures guide](https://help.qlik.com/en-US/stitch/replication/loading/understanding-loading-row-usage-for-nested-data-structures). |

A VARCHAR column is replicated to Amazon Redshift.

| **IF** | A `VARCHAR` column is replicated to Amazon Redshift. |
| --- | --- |
| **THEN** | Amazon Redshift will type the column as `VARCHAR(n)`, where `n` is the width of the widest record in the column.<br><br>For example: During the initial replication job, data in a `VARCHAR` column is found to have a width greater than `128`. Amazon Redshift will create type this column as `VARCHAR(256)` to accommodate the data. |

VARCHAR data is loaded that exceeds the current maximum size for the column.

| **IF** | `VARCHAR` data is loaded that exceeds the current maximum size for the column. |
| --- | --- |
| **THEN** | Amazon Redshift will widen the column to accommodate the width of the largest record up to the limit of `65535 bytes (64K -1)`.<br><br>For example: during the initial replication job, a `VARCHAR` column is created and typed as `VARCHAR(128)`.<br><br>During a subsequent job, Stitch identifies data for this column that exceeds the current size maximum of `128` but is less than `256`.<br><br>To accommodate the data, the column will become `VARCHAR(256)`. |

VARCHAR data is loaded that exceeds Amazon Redshift's supported limit.

| **IF** | VARCHAR data is loaded that exceeds Amazon Redshift’s supported limit. |
| --- | --- |
| **THEN** | Amazon Redshift will truncate the data to the maximum width of `65535 bytes (64K -1)`. |

A column containing date data with timezone info is replicated to Amazon Redshift.

| **IF** | A column containing date data with timezone info is replicated to Amazon Redshift. |
| --- | --- |
| **THEN** | Amazon Redshift will store the value as `TIMESTAMP WITHOUT TIMEZONE`. In Amazon Redshift, `TIMESTAMP WITHOUT TIME ZONE` data is stored without timezone information and expressed as UTC.<br><br>For more info on this data type, refer to [Amazon’s Datetime Type documentation](http://docs.aws.amazon.com/redshift/latest/dg/r_Datetime_types.html#r_Datetime_types-timestamp). |

A column contains timestamp data that is outside Amazon Redshift's supported range.

| **IF** | A column contains timestamp data that is outside Amazon Redshift’s supported range. |
| --- | --- |
| **THEN** | Amazon Redshift will reject the records that fall outside the supported range. |
| **AND** | The following error will display in the **Notifications** tab in Stitch:<br><br>```<br>timestamp out of range for Amazon Redshift on [TIMESTAMP]<br>```<br><br>`timestamp out of range for Amazon Redshift on [TIMESTAMP]`timestamp out of range for for Amazon Redshift on [[TIMESTAMP]<br><br><br>Rejected records will be logged in the `_sdc_rejected` table of the integration's schema. [Learn more](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table). |
| **FIX IT** | To resolve the error, offending values in the source must be changed to be within Amazon Redshift’s timestamp range.<br><br><br>Use the [`_sdc_rejected` table](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table) to identify the root of the issue. |

A column contains integer data that is outside Amazon Redshift's supported range.

| **IF** | A column contains integer data that is outside Amazon Redshift’s supported range. |
| --- | --- |
| **THEN** | Amazon Redshift will reject the records that fall outside the supported range. |
| **AND** | The following error will display in the **Notifications** tab in Stitch:<br><br>```<br>integer out of range for Amazon Redshift on [INTEGER]<br>```<br><br>`integer out of range for Amazon Redshift on [INTEGER]`integer out of range for for Amazon Redshift on [[INTEGER]<br><br><br>Rejected records will be logged in the `_sdc_rejected` table of the integration's schema. [Learn more](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table). |
| **FIX IT** | To resolve the error, offending values in the source must be changed to be within Amazon Redshift’s limit for integers.<br><br><br>Use the [`_sdc_rejected` table](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table) to identify the root of the issue. |

A column contains decimal data that is outside Amazon Redshift's supported range.

| **IF** | A column contains decimal data that is outside Amazon Redshift’s supported range. |
| --- | --- |
| **THEN** | Amazon Redshift will reject the records that fall outside the supported range. |
| **AND** | The following error will display in the **Notifications** tab in Stitch:<br><br>```<br>decimal out of range for Amazon Redshift on [DECIMAL]<br>```<br><br>`decimal out of range for Amazon Redshift on [DECIMAL]`decimal out of range for for Amazon Redshift on [[DECIMAL]<br><br><br>Rejected records will be logged in the `_sdc_rejected` table of the integration's schema. [Learn more](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table). |
| **FIX IT** | To resolve the error, offending values in the source must be changed to be within Amazon Redshift’s limit for decimal data.<br><br><br>Use the [`_sdc_rejected` table](https://help.qlik.com/en-US/stitch/replication/loading/system-tables-columns/rejected-records-system-table) to identify the root of the issue. |

[Back to top](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#)

## Schema change scenarios

Scenarios involving schema changes in the source or structural changes in the destination.

A new column is added in table already set to replicate.

| **IF** | A new column is added in table already set to replicate. |
| --- | --- |
| **THEN** | If the column has at least one non-`NULL` value in the source, the column will be created and appended to the end of the table in Amazon Redshift.<br><br>**Note**: If the table using either Key- or Log-based Incremental Replication, backfilled values for the column will only be replicated if:<br><br><ol> <li>The records’ Replication Key values are greater than or equal to the last saved maximum Replication Key value for the table, or</li> <li>The table is reset and a historical re-replication is queued.</li></ol> |

A new column is added by you to a Stitch-generated table in Amazon Redshift.

| **IF** | A new column is added by you to a Stitch-generated table in Amazon Redshift. |
| --- | --- |
| **THEN** | Columns may be added to tables created by Stitch as long as they are nullable, meaning columns don’t have `NOT NULL` constraints. |

A column is deleted at the source.

| **IF** | A column is deleted at the source. |
| --- | --- |
| **THEN** | How a deleted column is reflected in Amazon Redshift depends on the Replication Method used by the table:<br><br><ul> <li> <p><strong>Key-based Incremental:</strong> The column will remain in the destination, and default <code>NULL</code> values will be placed in it going forward.</p> </li> <li> <p><strong>Log-based Incremental:</strong> Changes to a source table - including adding or removing columns, changing data types, etc. - require manual intervention before replication can continue. Refer to the <a href="https://help.qlik.com/en-US/stitch/replication/replication-methods/log-based-incremental#limitation-3--structural-changes">Log-based Incremental Replication documentation</a> for more info.</p> </li> <li> <p><strong>Full Table</strong>: The column will remain in the destination, and default <code>NULL</code> values will be placed in it going forward.</p> </li></ul> |

You remove a column from a Stitch-replicated table in your destination.

| **IF** | You remove a column from a Stitch-replicated table in your destination. |
| --- | --- |
| **THEN** | The result of deleting a column from a Stitch-generated table depends on the **type** of column being removed:<br><br><ul> <li> <p><strong>Primary Key columns</strong>: Changing a table’s Primary Key(s) is not permitted in Amazon Redshift. If Primary Key columns are changed, Stitch will stop processing data for the table.</p> </li> <li> <p><strong>General columns</strong>:  If new data is detected for the removed column, Stitch will re-create it in Amazon Redshift. This refers to all columns that are not prepended by <code>_sdc</code> or suffixed by a data type. For example: <code>customer_zip</code>, but not <code>customer_zip__st</code>.</p> <p><strong>Note</strong>: An integration must support selecting columns AND you must deselect the column in Stitch for the column removal to be permanent.</p> </li> <li> <p><strong>_sdc columns</strong>: Removing a Stitch replication column will prevent Stitch from loading replicated data into Amazon Redshift.</p> </li> <li> <p><strong>Columns with data type suffixes</strong>: Removing a column created as result of accommodating <a href="https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#multiple-data-types">multiple data types</a> will prevent Stitch from loading replicated data into the table. This applies to columns with names such as: <code>customer_zip__st</code>, <code>customer_zip__int</code>, etc.</p> </li></ul> |

[Back to top](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#)

## Destination changes

Scenarios involving modifications made to the destination, such as the application of workload/performance management features or user privilege changes.

Indices are applied to Stitch-generated columns in the destination.

| **IF** | Indices are applied to Stitch-generated columns in the destination. |
| --- | --- |
| **THEN** | Stitch will respect the index application. |

SORT and/or DISTRIBUTION Keys are applied to Stitch-generated columns in the destination.

| **IF** | SORT and/or DISTRIBUTION Keys are applied to Stitch-generated columns in the destination. |
| --- | --- |
| **THEN** | Stitch will respect the application when loading data. |

You switch to a different destination of the same type.

| **IF** | You switch to a different destination of the same type. |
| --- | --- |
| **THEN** | This means the destination type is still Amazon Redshift, Stitch may just be connected a different database in Amazon Redshift.<br><br><ul> <li><strong>For tables using Key-based or Log-based Incremental Replication</strong>, replication will continue using the Replication’s Key last saved maximum value. To re-replicate historical data, resetting Replication Keys is required.</li> <li><strong>For tables using Full Table Replication</strong>, the table will be fully replicated into the new destination during the next successful job.</li> <li><strong>For webhook integrations,</strong> some data loss may be possible due to the continuous, real-time nature of webhooks. Historical data must either be backfilled or re-played.</li></ul> |

[Back to top](https://help.qlik.com/en-US/stitch/replication/reference/amazon-redshift/index#)