Skip to main content

CockroachDB

Overview

The CockroachDB source supports both Full Refresh and Incremental syncs. You can choose if this connector will copy only the new or updated data, or all rows in the tables and columns you set up for replication, every time a sync is run.

Resulting schema

The CockroachDb source does not alter the schema present in your database. Depending on the destination connected to this source, however, the schema may be altered. See the destination's documentation for more details.

Data type mapping

CockroachDb data types are mapped to the following data types when synchronizing data:

CockroachDb TypeResulting TypeNotes
bigintinteger
bitboolean
booleanboolean
characterstring
character varyingstring
datestring
double precisionstring
enumnumber
inetstring
intinteger
jsonstring
jsonbstring
numericnumber
smallintinteger
textstring
time with timezonestringmay be written as a native date type depending on the destination
time without timezonestringmay be written as a native date type depending on the destination
timestamp with timezonestringmay be written as a native date type depending on the destination
timestamp without timezonestringmay be written as a native date type depending on the destination
uuidstring

Note: arrays for all the above types as well as custom types are supported, although they may be de-nested depending on the destination.

Features

FeatureSupportedNotes
Full Refresh SyncYes
Incremental SyncYes
Change Data CaptureNo
SSL SupportYes

Getting started

Requirements

  1. CockroachDb v1.15.x or above
  2. Allow connections from Airbyte to your CockroachDb database (if they exist in separate VPCs)
  3. Create a dedicated read-only Airbyte user with access to all tables needed for replication

Setup guide

1. Make sure your database is accessible from the machine running Airbyte

This is dependent on your networking setup. The easiest way to verify if Airbyte is able to connect to your CockroachDb instance is via the check connection tool in the UI.

This step is optional but highly recommended to allow for better permission control and auditing. Alternatively, you can use Airbyte with an existing user in your database.

To create a dedicated database user, run the following commands against your database:

CREATE USER airbyte PASSWORD 'your_password_here';

Then give it access to the relevant schema:

GRANT USAGE ON SCHEMA <schema_name> TO airbyte

Note that to replicate data from multiple CockroachDb schemas, you can re-run the command above to grant access to all the relevant schemas, but you'll need to set up multiple sources connecting to the same db on multiple schemas.

Next, grant the user read-only access to the relevant tables. The simplest way is to grant read access to all tables in the schema as follows:

GRANT SELECT ON ALL TABLES IN SCHEMA <schema_name> TO airbyte;

# Allow airbyte user to see tables created in the future
ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT SELECT ON TABLES TO airbyte;

3. That's it!

Your database user should now be ready for use with Airbyte.

Changelog

Expand to review
VersionDatePull RequestSubject
0.2.32024-12-1849915Use a base image: airbyte/java-connector-base:1.0.0
0.2.22024-02-1335234Adopt CDK 0.20.4
0.2.12024-01-2434453bump CDK version
0.2.02023-12-1833485Removed LEGACY state
0.1.222023-03-2220760Removed redundant date-time datatypes formatting
0.1.212023-03-1424000Removed check method call on read.
0.1.202023-03-0623455For network isolation, source connector accepts a list of hosts it is allowed to connect
0.1.192022-12-1420436Consolidate date/time values mapping for JDBC sources
2022-10-1315535Update incremental query to avoid data missing when new data is inserted at the same time as a sync starts under non-CDC incremental mode
0.1.182022-09-0116394Added custom jdbc properties field
0.1.172022-09-0116238Emit state messages more frequently
0.1.162022-08-1814356DB Sources: only show a table can sync incrementally if at least one column can be used as a cursor field
0.1.132022-07-1414574Removed additionalProperties:false from JDBC source connectors
0.1.122022-04-2912480Query tables with adaptive fetch size to optimize JDBC memory consumption
0.1.112022-04-0611729Bump mina-sshd from 2.7.0 to 2.8.0
0.1.102022-02-2410235Fix Replication Failure due Multiple portal opens
0.1.92022-02-2110242Fixed cursor for old connectors that use non-microsecond format. Now connectors work with both formats
0.1.82022-02-1810242Updated timestamp transformation with microseconds
0.1.72022-02-1410256Add -XX:+ExitOnOutOfMemoryError JVM option
0.1.62022-02-0810173Improved discovering tables in case if user does not have permissions to any table
0.1.52021-12-249004User can see only permmited tables during discovery
0.1.42021-12-248958Add support for JdbcType.ARRAY
0.1.32021-10-107819Fixed Datatype errors during Cockroach DB parsing
0.1.22021-08-134699Added json config validator