Skip to main content

Redshift

This page guides you through the process of setting up the Redshift destination connector.

Prerequisites

The Airbyte Redshift destination allows you to sync data to Redshift.

This Redshift destination connector has two replication strategies:

  1. INSERT: Replicates data via SQL INSERT queries. This is built on top of the destination-jdbc code base and is configured to rely on JDBC 4.2 standard drivers provided by Amazon via Maven Central here as described in Redshift documentation here. Not recommended for production workloads as this does not scale well.

For INSERT strategy:

  • Host
  • Port
  • Username
  • Password
  • Schema
  • Database
    • This database needs to exist within the cluster provided.
  • JDBC URL Params (optional)
  1. COPY: Replicates data by first uploading data to an S3 bucket and issuing a COPY command. This is the recommended loading approach described by Redshift best practices. Requires an S3 bucket and credentials. Data is copied into S3 as multiple files with a manifest file.

Airbyte automatically picks an approach depending on the given configuration - if S3 configuration is present, Airbyte will use the COPY strategy and vice versa.

For COPY strategy:

  • S3 Bucket Name
    • See this to create an S3 bucket.
  • S3 Bucket Region
    • Place the S3 bucket and the Redshift cluster in the same region to save on networking costs.
  • Access Key Id
    • See this on how to generate an access key.
    • We recommend creating an Airbyte-specific user. This user will require read and write permissions to objects in the staging bucket.
  • Secret Access Key
    • Corresponding key to the above key id.

Optional parameters:

  • Bucket Path
    • The directory within the S3 bucket to place the staging data. For example, if you set this to yourFavoriteSubdirectory, we will place the staging data inside s3://yourBucket/yourFavoriteSubdirectory. If not provided, defaults to the root directory.
  • S3 Filename pattern
    • The pattern allows you to set the file-name format for the S3 staging file(s), next placeholders combinations are currently supported: {date}, {date:yyyy_MM}, {timestamp}, {timestamp:millis}, {timestamp:micros}, {part_number}, {sync_id}, {format_extension}. The pattern you supply will apply to anything under the Bucket Path. If this field is left blank, everything syncs under the Bucket Path. Please, don't use empty space and not supportable placeholders, as they won't recognized.
  • Purge Staging Data
    • Whether to delete the staging files from S3 after completing the sync. Specifically, the connector will create CSV files named bucketPath/namespace/streamName/syncDate_epochMillis_randomUuid.csv containing three columns (ab_id, data, emitted_at). Normally these files are deleted after the COPY command completes; if you want to keep them for other purposes, set purge_staging_data to false.

NOTE: S3 staging does not use the SSH Tunnel option for copying data, if configured. SSH Tunnel supports the SQL connection only. S3 is secured through public HTTPS access only. Subsequent typing and deduping queries on final table are executed over using provided SSH Tunnel configuration.

Step 1: Set up Redshift

  1. Log in to AWS Management console. If you don't have a AWS account already, you’ll need to create one in order to use the API.
  2. Go to the AWS Redshift service.
  3. Create and activate AWS Redshift cluster if you don't have one ready.
  4. (Optional) Allow connections from Airbyte to your Redshift cluster (if they exist in separate VPCs).
  5. (Optional) Create a staging S3 bucket (for the COPY strategy).

Permissions in Redshift

Airbyte writes data into two schemas, whichever schema you want your data to land in, e.g. my_schema and a "Raw Data" schema that Airbyte uses to improve ELT reliability. By default, this raw data schema is airbyte_internal but this can be overridden in the Redshift Destination's advanced settings. Airbyte also needs to query Redshift's SVV_TABLE_INFO table for metadata about the tables airbyte manages.

To ensure the airbyte_user has the correction permissions to:

  • create schemas in your database
  • grant usage to any existing schemas you want Airbyte to use
  • grant select to the svv_table_info table

You can execute the following SQL statements

GRANT CREATE ON DATABASE database_name TO airbyte_user; -- add create schema permission
GRANT usage, create on schema my_schema TO airbyte_user; -- add create table permission
GRANT SELECT ON TABLE SVV_TABLE_INFO TO airbyte_user; -- add select permission for svv_table_info

Optional Use of SSH Bastion Host

This connector supports the use of a Bastion host as a gateway to a private Redshift cluster via SSH Tunneling. Setup of the host is beyond the scope of this document but several tutorials are available online to fascilitate this task. Enter the bastion host, port and credentials in the destination configuration.

Step 2: Set up the destination connector in Airbyte

For Airbyte Cloud:

  1. Log into your Airbyte Cloud account.
  2. In the left navigation bar, click Destinations. In the top-right corner, click + new destination.
  3. On the destination setup page, select Redshift from the Destination type dropdown and enter a name for this connector.
  4. Fill in all the required fields to use the INSERT or COPY strategy.
  5. Click Set up destination.

For Airbyte Open Source:

  1. Go to local Airbyte page.
  2. In the left navigation bar, click Destinations. In the top-right corner, click + new destination.
  3. On the destination setup page, select Redshift from the Destination type dropdown and enter a name for this connector.
  4. Fill in all the required fields to use the INSERT or COPY strategy.
  5. Click Set up destination.

Supported sync modes

The Redshift destination connector supports the following sync modes:

  • Full Refresh
  • Incremental - Append Sync
  • Incremental - Append + Deduped

Performance considerations

Synchronization performance depends on the amount of data to be transferred. Cluster scaling issues can be resolved directly using the cluster settings in the AWS Redshift console.

Connector-specific features & highlights

Notes about Redshift Naming Conventions

From Redshift Names & Identifiers:

Standard Identifiers

  • Begin with an ASCII single-byte alphabetic character or underscore character, or a UTF-8 multibyte character two to four bytes long.
  • Subsequent characters can be ASCII single-byte alphanumeric characters, underscores, or dollar signs, or UTF-8 multibyte characters two to four bytes long.
  • Be between 1 and 127 bytes in length, not including quotation marks for delimited identifiers.
  • Contain no quotation marks and no spaces.

Delimited Identifiers

Delimited identifiers (also known as quoted identifiers) begin and end with double quotation marks ("). If you use a delimited identifier, you must use the double quotation marks for every reference to that object. The identifier can contain any standard UTF-8 printable characters other than the double quotation mark itself. Therefore, you can create column or table names that include otherwise illegal characters, such as spaces or the percent symbol. ASCII letters in delimited identifiers are case-insensitive and are folded to lowercase. To use a double quotation mark in a string, you must precede it with another double quotation mark character.

Therefore, Airbyte Redshift destination will create tables and schemas using the Unquoted identifiers when possible or fallback to Quoted Identifiers if the names are containing special characters.

Data Size Limitations

Redshift specifies a maximum limit of 16MB (and 65535 bytes for any VARCHAR fields within the JSON record) to store the raw JSON record data. Thus, when a row is too big to fit, the destination connector will do one of the following.

  1. Null the value if the varchar size > 65535, The corresponding key information is added to _airbyte_meta.
  2. Null the whole record while trying to preserve the Primary Keys and cursor field declared as part of your stream configuration, if the total record size is > 16MB.
    • For DEDUPE sync mode, if we do not find Primary key(s), we fail the sync.
    • For OVERWRITE and APPEND mode, syncs will succeed with empty records emitted, if we fail to find Primary key(s).

See AWS docs for SUPER and SUPER limitations.

Encryption

All Redshift connections are encrypted using SSL.

Output schema

Each stream will be output into its own raw table in Redshift. Each table will contain 3 columns:

  • _airbyte_raw_id: a uuid assigned by Airbyte to each event that is processed. The column type in Redshift is VARCHAR.
  • _airbyte_extracted_at: a timestamp representing when the event was pulled from the data source. The column type in Redshift is TIMESTAMP WITH TIME ZONE.
  • _airbyte_loaded_at: a timestamp representing when the row was processed into final table. The column type in Redshift is TIMESTAMP WITH TIME ZONE.
  • _airbyte_data: a json blob representing with the event data. The column type in Redshift is SUPER.

Data type map

Airbyte typeRedshift type
STRINGVARCHAR
STRING (BASE64)VARCHAR
STRING (BIG_NUMBER)VARCHAR
STRING (BIG_INTEGER)VARCHAR
NUMBERDECIMAL / NUMERIC
INTEGERBIGINT / INT8
BOOLEANBOOLEAN / BOOL
STRING (TIMESTAMP_WITH_TIMEZONE)TIMESTAMPTZ / TIMESTAMP WITH TIME ZONE
STRING (TIMESTAMP_WITHOUT_TIMEZONE)TIMESTAMP
STRING (TIME_WITH_TIMEZONE)TIMETZ / TIME WITH TIME ZONE
STRING (TIME_WITHOUT_TIMEZONE)TIME
DATEDATE
OBJECTSUPER
ARRAYSUPER

Changelog

Expand to review
VersionDatePull RequestSubject
3.1.12024-06-2639008Internal code changes
3.1.02024-06-2639141Remove nonfunctional "encrypted staging" option
3.0.02024-06-0438886Remove standard inserts mode
2.6.42024-05-3138825Adopt CDK 0.35.15
2.6.32024-05-3138803Source auto-conversion to Kotlin
2.6.22024-05-1438189adding an option to DROP CASCADE on resets
2.6.12024-05-13#38126Adapt to signature changes in StreamConfig
2.6.02024-05-08#37713Remove option for incremental typing and deduping
2.5.02024-05-06#34613Upgrade Redshift driver to work with Cluster patch 181; Adapt to CDK 0.33.0; Minor signature changes
2.4.32024-04-10#36973Limit the Standard inserts SQL statement to less than 16MB
2.4.22024-04-05#36365Remove unused config option
2.4.12024-04-04#36846Remove duplicate S3 Region
2.4.02024-03-21#36589Adapt to Kotlin cdk 0.28.19
2.3.22024-03-21#36374Supress Jooq DataAccessException error message in logs
2.3.12024-03-18#36255Mark as Certified-GA
2.3.02024-03-18#36203CDK 0.25.0; Record nulling for VARCHAR > 64K & record > 16MB (super limit)
2.2.02024-03-14#35981CDK 0.24.0; _airbyte_meta in Raw table for tracking upstream data modifications.
2.1.102024-03-07#35899Adopt CDK 0.23.18; Null safety check in state parsing
2.1.92024-03-04#35316Update to CDK 0.23.11; Adopt migration framework
2.1.82024-02-09#35354Update to CDK 0.23.0; Gather required initial state upfront, remove dependency on svv_table_info for table empty check
2.1.72024-02-09#34562Switch back to jooq-based sql execution for standard insert
2.1.62024-02-08#34502Update to CDK version 0.17.0
2.1.52024-01-30#34680Update to CDK version 0.16.3
2.1.42024-01-29#34634Use lowercase raw schema and table in T+D CDK changes
2.1.32024-01-26#34544Proper string-escaping in raw tables
2.1.22024-01-24#34451Improve logging for unparseable input
2.1.12024-01-24#34458Improve error reporting
2.1.02024-01-24#34467Upgrade CDK to 0.14.0
2.0.02024-01-23#34077Destinations V2
0.8.02024-01-18#34236Upgrade CDK to 0.13.0
0.7.152024-01-11#34186Update check method with svv_table_info permission check, fix bug where s3 staging files were not being deleted.
0.7.142024-01-08#34014Update order of options in spec
0.7.132024-01-05#33948Fix NPE when prepare tables fail; Add case sensitive session for super; Bastion heartbeats added
0.7.122024-01-03#33924Add new ap-southeast-3 AWS region
0.7.112024-01-04#33730Internal code structure changes
0.7.102024-01-04#33728Allow users to disable final table creation
0.7.92024-01-03#33877Fix Jooq StackOverflowError
0.7.82023-12-28#33788Thread-safe fix for file part names (s3 staging files)
0.7.72024-01-04#33728Add option to only type and dedupe at the end of the sync
0.7.62023-12-20#33704Only run T+D on a stream if it had any records during the sync
0.7.52023-12-18#33124Make Schema Creation Separate from Table Creation
0.7.42023-12-13#33369Use jdbc common sql implementation
0.7.32023-12-12#33367DV2: fix migration logic
0.7.22023-12-11#33335DV2: improve data type mapping
0.7.12023-12-11#33307DV2: improve data type mapping No changes
0.7.02023-12-05#32326Opt in beta for v2 destination
0.6.112023-11-29#32888Use the new async framework.
0.6.102023-11-06#32193Adopt java CDK version 0.4.1.
0.6.92023-10-10#31083Fix precision of numeric values in async destinations
0.6.82023-10-10#31218Clarify configuration groups
0.6.72023-10-06#31153Increase jvm GC retries
0.6.62023-10-06#31129Reduce async buffer size
0.6.52023-08-18#28619Fix duplicate staging object names in concurrent environment (e.g. async)
0.6.42023-08-10#28619Use async method for staging
0.6.32023-08-07#29188Internal code refactoring
0.6.22023-07-24#28618Add hooks in preparation for destinations v2 implementation
0.6.12023-07-14#28345Increment patch to trigger a rebuild
0.6.02023-06-27#27993destination-redshift will fail syncs if records or properties are too large, rather than silently skipping records and succeeding
0.5.02023-06-27#27781License Update: Elv2
0.4.92023-06-21#27555Reduce image size
0.4.82023-05-17#26165Internal code change for future development (install normalization packages inside connector)
0.4.72023-05-01#25698Remove old VARCHAR to SUPER migration Java functionality
0.4.62023-04-27#25346Internal code cleanup
0.4.52023-03-30#24736Improve behavior when throttled by AWS API
0.4.42023-03-29#24671Fail faster in certain error cases
0.4.32023-03-17#23788S3-Parquet: added handler to process null values in arrays
0.4.22023-03-10#23931Added support for periodic buffer flush
0.4.12023-03-10#23466Changed S3 Avro type from Int to Long
0.4.02023-02-28#23523Add SSH Bastion Host configuration options
0.3.562023-01-26#21890Fixed configurable parameter for number of file buffers
0.3.552023-01-26#20631Added support for destination checkpointing with staging
0.3.542023-01-18#21087Wrap Authentication Errors as Config Exceptions
0.3.532023-01-03#17273Flatten JSON arrays to fix maximum size check for SUPER field
0.3.522022-12-30#20879Added configurable parameter for number of file buffers (⛔ this version has a bug and will not work; use 0.3.56 instead)
0.3.512022-10-26#18434Fix empty S3 bucket path handling
0.3.502022-09-14#15668Wrap logs in AirbyteLogMessage
0.3.492022-09-01#16243Fix Json to Avro conversion when there is field name clash from combined restrictions (anyOf, oneOf, allOf fields)
0.3.482022-09-01Added JDBC URL params
0.3.472022-07-15#14494Make S3 output filename configurable.
0.3.462022-06-27#14190Correctly cleanup S3 bucket when using a configured bucket path for S3 staging operations.
0.3.452022-06-25#13916Use the configured bucket path for S3 staging operations.
0.3.442022-06-24#14114Remove "additionalProperties": false from specs for connectors with staging
0.3.432022-06-24#13690Improved discovery for NOT SUPER column
0.3.422022-06-21#14013Add an option to use encryption with staging in Redshift Destination
0.3.402022-06-17#13753Deprecate and remove PART*SIZE_MB fields from connectors based on StreamTransferManager
0.3.392022-06-02#13415Add dropdown to select Uploading Method.
PLEASE NOTICE: After this update your uploading method will be set to Standard, you will need to reconfigure the method to use S3 Staging again.
0.3.372022-05-23#13090Removed redshiftDataTmpTableMode. Some refactoring.
0.3.362022-05-23#12820Improved 'check' operation performance
0.3.352022-05-18#12940Fixed maximum record size for SUPER type
0.3.342022-05-16#12869Fixed NPE in S3 staging check
0.3.332022-05-04#12601Apply buffering strategy for S3 staging
0.3.322022-04-20#12085Fixed bug with switching between INSERT and COPY config
0.3.312022-04-19#12064Added option to support SUPER datatype in _airbyte_raw*** table
0.3.292022-04-05#11729Fixed bug with dashes in schema name
0.3.282022-03-18#11254Fixed missing records during S3 staging
0.3.272022-02-25#10421Refactor JDBC parameters handling
0.3.252022-02-14#9920Updated the size of staging files for S3 staging. Also, added closure of S3 writers to staging files when data has been written to an staging file.
0.3.242022-02-14#10256Add -XX:+ExitOnOutOfMemoryError JVM option
0.3.232021-12-16#8855Add purgeStagingData option to enable/disable deleting the staging data
0.3.222021-12-15#8607Accept a path for the staging data
0.3.212021-12-10#8562Moving classes around for better dependency management
0.3.202021-11-08#7719Improve handling of wide rows by buffering records based on their byte size rather than their count
0.3.192021-10-21#7234Allow SSL traffic only
0.3.172021-10-12#6965Added SSL Support
0.3.162021-10-11#6949Each stream was split into files of 10,000 records each for copying using S3 or GCS
0.3.142021-10-08#5924Fixed AWS S3 Staging COPY is writing records from different table in the same raw table
0.3.132021-09-02#5745Disable STATUPDATE flag when using S3 staging to speed up performance
0.3.122021-07-21#3555Enable partial checkpointing for halfway syncs
0.3.112021-07-20#4874allow additionalProperties in connector spec