Skip to main content

Google Cloud Storage (GCS)

This page contains the setup guide and reference information for the Google Cloud Storage (GCS) source connector.

info

Cloud storage may incur egress costs. Egress refers to data that is transferred out of the cloud storage system, such as when you download files or access them from a different location. For more information, see the Google Cloud Storage pricing guide.

Prerequisites

  • Google account or JSON credentials for the service account that have access to GCS. For more details check instructions
  • GCS bucket
  • The list of streams to sync

Setup guide

Set up Google Cloud Storage (GCS)

Create a Service Account

First, you need to select existing or create a new project in the Google Cloud Console:

  1. Sign in to the Google Account.
  2. Go to the Service Accounts page.
  3. Click Create service account.
  4. Create a JSON key file for the service user. The contents of this file will be provided as the service_account in the UI.

Grant permission to GCS

Use the service account ID from above, grant read access to your target bucket. Click here for more details.

Set up the Google Cloud Storage (GCS) connector in Airbyte

For Airbyte Cloud:

  1. Log into your Airbyte Cloud account.
  2. Click Sources and then click + New source.
  3. On the Set up the source page, select Google Cloud Storage (GCS) from the Source type dropdown.
  4. Enter a name for the Google Cloud Storage (GCS) connector.
  5. Select authorization type:
    1. Authenticate via Google (OAuth) from the Authentication dropdown, click Sign in with Google and complete the authentication workflow.
    2. Service Account Information and paste the service account JSON key to the Service Account Information field .
  6. Paste the service account JSON key to the Service Account Information field .
  7. Enter your GCS bucket name to the Bucket field.
  8. Add a stream:
    1. Give a Name to the stream
    2. In the Format box, use the dropdown menu to select the format of the files you'd like to replicate. Toggling the Optional fields button within the Format box will allow you to enter additional configurations based on the selected format. For a detailed breakdown of these settings, refer to the File Format section below.
    3. Optionally, enter the Globs which dictates which files to be synced. This is a regular expression that allows Airbyte to pattern match the specific files to replicate. If you are replicating all the files within your bucket, use ** as the pattern. For more precise pattern matching options, refer to the Path Patterns section below.
    4. (Optional) - If you want to enforce a specific schema, you can enter a Input schema. By default, this value is set to {} and will automatically infer the schema from the file(s) you are replicating. For details on providing a custom schema, refer to the User Schema section.
  9. Configure the optional Start Date parameter that marks a starting date and time in UTC for data replication. Any files that have not been modified since this specified date/time will not be replicated. Use the provided datepicker (recommended) or enter the desired date programmatically in the format YYYY-MM-DDTHH:mm:ssZ. Leaving this field blank will replicate data from all files that have not been excluded by the Path Pattern and Path Prefix.
  10. Click Set up source and wait for the tests to complete.

For Airbyte Open Source:

  1. Navigate to the Airbyte Open Source dashboard.
  2. Click Sources and then click + New source.
  3. On the Set up the source page, select Google Cloud Storage (GCS) from the Source type dropdown.
  4. Enter a name for the Google Cloud Storage (GCS) connector.
  5. Select authorization type:
    1. Authenticate via Google (OAuth) from the Authentication dropdown, click Sign in with Google and complete the authentication workflow.
    2. Service Account Information and paste the service account JSON key to the Service Account Information field .
  6. Paste the service account JSON key to the Service Account Information field .
  7. Enter your GCS bucket name to the Bucket field.
  8. Add a stream:
    1. Give a Name to the stream
    2. In the Format box, use the dropdown menu to select the format of the files you'd like to replicate. Toggling the Optional fields button within the Format box will allow you to enter additional configurations based on the selected format. For a detailed breakdown of these settings, refer to the File Format section below.
    3. Optionally, enter the Globs which dictates which files to be synced. This is a regular expression that allows Airbyte to pattern match the specific files to replicate. If you are replicating all the files within your bucket, use ** as the pattern. For more precise pattern matching options, refer to the Path Patterns section below.
    4. (Optional) - If you want to enforce a specific schema, you can enter a Input schema. By default, this value is set to {} and will automatically infer the schema from the file(s) you are replicating. For details on providing a custom schema, refer to the User Schema section.
  9. Configure the optional Start Date parameter that marks a starting date and time in UTC for data replication. Any files that have not been modified since this specified date/time will not be replicated. Use the provided datepicker (recommended) or enter the desired date programmatically in the format YYYY-MM-DDTHH:mm:ssZ. Leaving this field blank will replicate data from all files that have not been excluded by the Path Pattern and Path Prefix.
  10. Click Set up source and wait for the tests to complete.

File urls

The Google Cloud Storage (GCS) source connector uses signed url to work with files when source authenticated with Service Account Information and gs://{blob.bucket.name}/{blob.name} when source authenticated via Google (OAuth). This is important to know that File urls are used in the connection state. So if you change authorization type, and you use Incremental sync the next sync will not use old state and reread provided files in Full Refresh mode(like initial sync), next syncs will be Incremental as expected.

Path Patterns

(tl;dr -> path pattern syntax using wcmatch.glob. GLOBSTAR and SPLIT flags are enabled.)

This connector can sync multiple files by using glob-style patterns, rather than requiring a specific path for every file. This enables:

  • Referencing many files with just one pattern, e.g. ** would indicate every file in the folder.
  • Referencing future files that don't exist yet (and therefore don't have a specific path).

You must provide a path pattern. You can also provide many patterns split with | for more complex directory layouts.

Each path pattern is a reference from the root of the folder, so don't include the root folder name itself in the pattern(s).

Some example patterns:

  • ** : match everything.
  • **/*.csv : match all files with specific extension.
  • myFolder/**/*.csv : match all csv files anywhere under myFolder.
  • */** : match everything at least one folder deep.
  • */*/*/** : match everything at least three folders deep.
  • **/file.*|**/file : match every file called "file" with any extension (or no extension).
  • x/*/y/* : match all files that sit in sub-folder x -> any folder -> folder y.
  • **/prefix*.csv : match all csv files with specific prefix.
  • **/prefix*.parquet : match all parquet files with specific prefix.

Let's look at a specific example, matching the following folder layout (MyFolder is the folder specified in the connector config as the root folder, which the patterns are relative to):

MyFolder
-> log_files
-> some_table_files
-> part1.csv
-> part2.csv
-> images
-> more_table_files
-> part3.csv
-> extras
-> misc
-> another_part1.csv

We want to pick up part1.csv, part2.csv and part3.csv (excluding another_part1.csv for now). We could do this a few different ways:

  • We could pick up every csv file called "partX" with the single pattern **/part*.csv.
  • To be a bit more robust, we could use the dual pattern some_table_files/*.csv|more_table_files/*.csv to pick up relevant files only from those exact folders.
  • We could achieve the above in a single pattern by using the pattern *table_files/*.csv. This could however cause problems in the future if new unexpected folders started being created.
  • We can also recursively wildcard, so adding the pattern extras/**/*.csv would pick up any csv files nested in folders below "extras", such as "extras/misc/another_part1.csv".

As you can probably tell, there are many ways to achieve the same goal with path patterns. We recommend using a pattern that ensures clarity and is robust against future additions to the directory structure.

User Schema

When using the Avro, Jsonl, CSV or Parquet format, you can provide a schema to use for the output stream. Note that this doesn't apply to the experimental Document file type format.

Providing a schema allows for more control over the output of this stream. Without a provided schema, columns and datatypes will be inferred from the first created file in the bucket matching your path pattern and suffix. This will probably be fine in most cases but there may be situations you want to enforce a schema instead, e.g.:

  • You only care about a specific known subset of the columns. The other columns would all still be included, but packed into the _ab_additional_properties map.
  • Your initial dataset is quite small (in terms of number of records), and you think the automatic type inference from this sample might not be representative of the data in the future.
  • You want to purposely define types for every column.
  • You know the names of columns that will be added to future data and want to include these in the core schema as columns rather than have them appear in the _ab_additional_properties map.

Or any other reason! The schema must be provided as valid JSON as a map of {"column": "datatype"} where each datatype is one of:

  • string
  • number
  • integer
  • object
  • array
  • boolean
  • null

For example:

  • {"id": "integer", "location": "string", "longitude": "number", "latitude": "number"}
  • {"username": "string", "friends": "array", "information": "object"}

File Format Settings

Avro

  • Convert Double Fields to Strings: Whether to convert double fields to strings. This is recommended if you have decimal numbers with a high degree of precision because there can be a loss precision when handling floating point numbers.

CSV

Since CSV files are effectively plain text, providing specific reader options is often required for correct parsing of the files. These settings are applied when a CSV is created or exported so please ensure that this process happens consistently over time.

  • Header Definition: How headers will be defined. User Provided assumes the CSV does not have a header row and uses the headers provided and Autogenerated assumes the CSV does not have a header row and the CDK will generate headers using for f{i} where i is the index starting from 0. Else, the default behavior is to use the header from the CSV file. If a user wants to autogenerate or provide column names for a CSV having headers, they can set a value for the "Skip rows before header" option to ignore the header row.
  • Delimiter: Even though CSV is an acronym for Comma Separated Values, it is used more generally as a term for flat file data that may or may not be comma separated. The delimiter field lets you specify which character acts as the separator. To use tab-delimiters, you can set this value to \t. By default, this value is set to ,.
  • Double Quote: This option determines whether two quotes in a quoted CSV value denote a single quote in the data. Set to True by default.
  • Encoding: Some data may use a different character set (typically when different alphabets are involved). See the list of allowable encodings here. By default, this is set to utf8.
  • Escape Character: An escape character can be used to prefix a reserved character and ensure correct parsing. A commonly used character is the backslash (\). For example, given the following data:
Product,Description,Price
Jeans,"Navy Blue, Bootcut, 34\"",49.99

The backslash (\) is used directly before the second double quote (") to indicate that it is not the closing quote for the field, but rather a literal double quote character that should be included in the value (in this example, denoting the size of the jeans in inches: 34" ).

Leaving this field blank (default option) will disallow escaping.

  • False Values: A set of case-sensitive strings that should be interpreted as false values.
  • Null Values: A set of case-sensitive strings that should be interpreted as null values. For example, if the value 'NA' should be interpreted as null, enter 'NA' in this field.
  • Quote Character: In some cases, data values may contain instances of reserved characters (like a comma, if that's the delimiter). CSVs can handle this by wrapping a value in defined quote characters so that on read it can parse it correctly. By default, this is set to ".
  • Skip Rows After Header: The number of rows to skip after the header row.
  • Skip Rows Before Header: The number of rows to skip before the header row.
  • Strings Can Be Null: Whether strings can be interpreted as null values. If true, strings that match the null_values set will be interpreted as null. If false, strings that match the null_values set will be interpreted as the string itself.
  • True Values: A set of case-sensitive strings that should be interpreted as true values.

JSONL

  • Schemaless: When enabled, syncs will not validate or structure records against the stream's schema.

Parquet

  • Convert Double Fields to Strings: Whether to convert double fields to strings. This is recommended if you have decimal numbers with a high degree of precision because there can be a loss precision when handling floating point numbers.

Unstructured document format

  • Parsing Strategy: The strategy used to parse documents. fast extracts text directly from the document which doesn't work for all files. ocr_only is more reliable, but slower. hi_res is the most reliable, but requires an API key and a hosted instance of unstructured and can't be used with local mode. See the unstructured.io documentation for more details.
  • Processing: Processing configuration. Options:
    • Local - Process files locally, supporting fast and ocr modes. This is the default option.
    • Via API - Process files via an API, using the hi_res mode. This option is useful for increased performance and accuracy, but requires an API key and a hosted instance of unstructured.
  • Skip Unprocessable Files: If true, skip files that cannot be parsed and pass the error message along as the _ab_source_file_parse_error field. If false, fail the sync.
  • Schemaless: When enabled, syncs will not validate or structure records against the stream's schema.

Excel

  • Schemaless: When enabled, syncs will not validate or structure records against the stream's schema.

Supported sync modes

The Google Cloud Storage (GCS) source connector supports the following sync modes:

FeatureSupported?(Yes/No)Notes
Full Refresh SyncYes
Incremental SyncYes

Supported Streams

Google Cloud Storage (GCS) supports following file formats:

  • avro
  • jsonl
  • csv
  • parquet
  • unstructured document format
  • excel

Reference

Config fields reference

Field
Type
Property name
array<object>
streams
object
credentials
string
bucket
string
start_date

Changelog

Expand to review
VersionDatePull RequestSubject
0.8.02024-10-2845414Add support for OAuth authentication
0.7.42024-10-1246858Update dependencies
0.7.32024-10-0546458Update dependencies
0.7.22024-09-2846178Update dependencies
0.7.12024-09-2445850Add integration tests
0.7.02024-09-2445671Add .zip files support
0.6.92024-09-2145798Update dependencies
0.6.82024-09-1945092Update CDK v5; Fix OSError not raised in stream_reader.open_file
0.6.72024-09-1445492Update dependencies
0.6.62024-09-0745232Update dependencies
0.6.52024-08-3145010Update dependencies
0.6.42024-08-2744796Fix empty list of globs when prefix empty
0.6.32024-08-2644781Set file signature URL expiration limit default to max
0.6.22024-08-2444733Update dependencies
0.6.12024-08-1744285Update dependencies
0.6.02024-08-1544015Add support for all FileBasedSpec file types
0.5.02024-08-1444070Update CDK v4 and Python 3.10 dependencies
0.4.152024-08-1243733Update dependencies
0.4.142024-08-1043512Update dependencies
0.4.132024-08-0343236Update dependencies
0.4.122024-07-2742693Update dependencies
0.4.112024-07-2042312Update dependencies
0.4.102024-07-1341865Update dependencies
0.4.92024-07-1041430Update dependencies
0.4.82024-07-0941148Update dependencies
0.4.72024-07-0641015Update dependencies
0.4.62024-06-2640540Update dependencies
0.4.52024-06-2540391Update dependencies
0.4.42024-06-2440234Update dependencies
0.4.32024-06-2240089Update dependencies
0.4.22024-06-0639255[autopull] Upgrade base image to v1.2.2
0.4.12024-05-2938696Avoid error on empty stream when running discover
0.4.02024-03-2136373Add Gzip and Bzip compression support. Manage dependencies with Poetry.
0.3.72024-02-0634936Bump CDK version to avoid missing SyncMode errors
0.3.62024-01-3034681Unpin CDK version to make compatible with the Concurrent CDK
0.3.52024-01-3034661Pin CDK version until upgrade for compatibility with the Concurrent CDK
0.3.42024-01-1134158Fix issue in stream reader for document file type parser
0.3.32023-12-0633187Bump CDK version to hide source-defined primary key
0.3.22023-11-1632608Improve document file type parser
0.3.12023-11-1332357Improve spec schema
0.3.02023-10-1131212Migrated to file based CDK
0.2.02023-06-2627725License Update: Elv2
0.1.02023-02-1623186New Source: GCS