Cloud Storage Load

Cloud Storage Load


This article is specific to the following platforms - Snowflake - BigQuery.

Cloud Storage Load

The Cloud Storage Load Component lets users load data stored on the Google Cloud Storage service into an existing Snowflake table. Many of the configuration settings on this component have sensible defaults, mirroring the defaults provided by Snowflake when that option is not specified

The Cloud Storage Load Component lets users load data stored on the Google Cloud Storage service into an existing BigQuery table. Many of the configuration settings on this component have sensible defaults, mirroring the defaults provided by BigQuery when that option is not specified

Note: This component requires working Google Cloud Storage credentials with "read" access to the source data file(s).


Snowflake Properties

Property Setting Description
Name Text Input the descriptive name for the component.
Stage Select Select your stage. To learn more about stages in Matillion ETL, read our Manage Stages guide.
Google Storage URL Location String/Select Input, or select via the file path tree, the URL of the Google Storage bucket from which to retrieve files. This follows a format such as gs://<bucket-name>/<path>.
Storage Integration Select Choose your Google Cloud Storage Integration. Integrations are required to permit Snowflake to read data from and write to a Google Cloud Storage bucket. Integrations must be set up in advance of selecting them in Matillion ETL. To learn more about setting up a storage integration, read our Storage Integration Setup Guide.
Pattern Regex Pattern A regular expression pattern string that specifies the file names and/or paths to match. Files should be preceded by .*. E.g. .*.file_name.file_type
For more information, please refer to the Snowflake documentation.
Warehouse Select Choose a Snowflake warehouse to perform the data load. For more information about warehouses, please refer to the Snowflake documentation.
Database Select Choose a Snowflake database to create the new table in. For more information about databases, please refer to the Snowflake documentation.
Schema Select Choose a Snowflake schema. A Snowflake schema is a logical grouping of database objects such as tables or views.
Target Table Select Choose a target table to load.
Warning: This table will be recreated and drop any existing table of the same name upon each run.
Load Columns Multiple Select Choose which columns from your selected target table to load.
Format Select Select the format.
File Type Select Choose the file type for the files you wish to load. Available file types are: AVRO, CSV, JSON, ORC, PARQUET, and XML.
Note: Component properties beneath this property will change depending on the chosen file type. Matillion ETL provides settings based on the specific file type.
For additional information on file type options, please refer to the Snowflake documentation.
Compression Select Select the compression method if you wish to compress your data. If you do not wish to compress at all, select NONE. The default setting is AUTO.
Record Delimiter String (CSV only) Input a delimiter for records. This can be one or more singlebyte or multibute chatracters that separate records in an input file.
Notes:
  • Accepted characters include common escape sequences, octal values (prefixed by \\), or hex values (prefixed by 0x). Also accepts a value of NONE.
  • This delimiter is limited to a maximum of 20 characters.
  • While multi-character delimiters are supported, the record delimiter cannot be a substring of the field delimiter, and vice versa. For example, if the record delimiter is "aa", the field delimiter cannot be "aabb".
  • The specified delimiter must be a valid UTF-8 character and not a random sequence of bytes.
  • Do not specify characters used for other file type options such as Escape or Escape Unenclosed Field.
  • Default setting is new line character.
Field Delimiter String (CSV only) Input a delimiter for fields. This can be one or more singlebyte or multibyte characters that separate fields in an input file.
Notes:
  1. Accepted characters include common escape sequences, octal values (prefixed by \\), or hex values (prefixed by 0x). Also accepts a value of NONE.
  2. This delimiter is limited to a maximum of 20 characters.
  3. While multi-character delimiters are supported, the field delimiter cannot be a substring of the record delimiter, and vice versa. For example, if the field delimiter is "aa", the record delimiter cannot be "aabb".
  4. The specified delimiter must be a valid UTF-8 character and not a random sequence of bytes.
  5. Do not specify characters used for other file type options such as Escape or Escape Unenclosed Field.
  6. Default setting is a comma (,).
Skip Header Integer (CSV only) Specify the number of rows to skip. The default is 0.
Date Format String (CSV only) Specify the date format. Snowflake accepts dates in the most common forms, including YYYY-MM-DD and DD-MON-YYYY among others. Additionally, all accepted timestamps are valid inputs for dates.
Please refer to the Snowflake documentation for more information about date and time formats.
Time Format String (CSV only) Specify the time format. Snowflake supports a single TIME data type, for storing times in the form of HH:MI:SS. TIME supports an optional precision parameter for fractional seconds, e.g. TIME(3). Time precision ranges between 0 (seconds) to 9 (nanoseconds). The default precision is 9. Please refer to the Snowflake documentation for more information about time and date formats.
Timestamp Format String (CSV only) Specify the timestamp format. Snowflake supports three variations of timestamp: TIMESTAMP_LTZ, TIMESTAMP_NTZ, and TIMESTAMP_TZ. To learn more, please consult the Snowflake documentation.
Escape String (CSV only) Specify a single character to be used as the escape character for any field values. Default is NONE.
Escape Unenclosed Field String (CSV only) Single character string used as the escape character for unenclosed field values only. Default is \\.
Trim Space True | False (CSV only) Specify whether to remove white space from fields (True) or not (False). Default setting is False.
Field Optionally Enclosed String (CSV only) Specify a character used to enclose strings. The value can be NONE, single quote character ('), or double quote character ("). To use the single quote character, use the octal or hex representation (0x27) or the double single-quoted escape (''). Default is NONE.
Note: When a field contains one of these characters, escape the field using the same character. For example, to escape a string like this: 1 "2" 3, use double quotation to escape, like this: 1 ""2"" 3.
Null If String (CSV only) Specify any strings to convert to and from null values. Press + to add strings. Default is empty.
Error On Column Count Mismatch True | False (CSV only) Specify whether to generate an error (True) if the number of delimited columns in an input file does not match the number of columns in the corresponding table. If set to False an error is not generated and the load continues. If the file is successfully loaded in this case:
  • Where the input file contains records with more fields than columns in the table, the matching fields are loaded in order of occurrence in the file, and the remaining fields are not loaded.
  • Where the input file contains records with fewer fields than columns in the table, the non-matching columns in the table are loaded with NULL values.
In Matillion ETL, the default setting is False.
Empty Field As Null True | False (CSV only) Specify whether to insert NULL values for empty fields in an input file. Default is True.
Encoding Type Select (CSV only) Select the string that specifies the character set of the source data when loading data into a table. Please refer to the Snowflake documentation for more information.
Enable Octal True | False (JSON only) Select True to enable the parsing of octal values. Default setting is False.
Allow Duplicates True | False (JSON only) Select True to allow duplicate object field names. Default setting is False.
Strip Outer Array True | False (JSON only) Select True to instruct the JSON parser to remote outer brackets. Default setting is False.
Strip Null Values True | False (JSON only) Select True to instruct the JSON parser to remove any object fields or array elements containing null values. Default setting is False.
Ignore UTF8 Errors True | False (JSON, XML only) Select True to replace any invalid UTF-8 sequences with Unicode characters. If set to False, UTF-8 errors will not produce an error in the job run. Default setting is False.
Preserve Space True | False Select True for the XML parser to preserve leading and trailing spaces in element content. Default setting is False.
Strip Outer Element True | False Select True for the XML parser to strip out any outer XML elements, exposing 2nd level elements as separate documents. Default setting is False.
Disable Snowflake Data True | False Select True if you wish the XML parser to not recognise Snowflake semi-structured data tags. Default setting is False.
Disable Auto Convert True | False Select True to specify that the XML parser will disable automatic conversion of numeric and Boolean values from text to native representations. Default setting is False.
On Error Select Decide how to proceed upon an error.
  1. 1. Abort Statement: Aborts the load if any error is encountered.
  2. 2. Continue: Continue loading the file.
  3. 3. Skip File: Skip file if any errors are encountered in the file.
  4. 4. Skip File When n Errors: Skip file when the number of errors in the file is equal to or greater than the specified number in the next property, n.
  5. 5. Skip File When n% Errors: Skip file when the percentage of errors in the file exceeds the specified percentage of n.

Default setting is Abort Statement.
n Integer Specify the number of errors or the percentage of errors required for Matillion ETL to skip the file.
Note: This parameter only accepts integer characters. % is not accepted. Specify percentages as a number only.
Size Limit (B) Integer Specify the maximum size, in bytes, of data to be loaded for a given COPY statement. If the maximum is exceeded, the COPY operation discontinues loading files. For more information, please refer to the Snowflake documentation.
Purge Files True | False Select True to purge data files after the data is successfully loaded. Default setting is False.
Truncate Columns True | False When True, Matillion ETL will automatically truncate strings to the target column length.
When False, the COPY statement produces an error if a loaded string exceeds the target column length.
Default setting is False.
Force Load True | False Select True to load all files, regardless of whether they have been loaded previously and haven't changed since they were loaded. Default setting is False.
Note: When set to True, this option reloads files and can lead to duplicated data in a table.

BigQuery Properties

Property Setting Description
Name Text Input the descriptive name for the component.
Project Select Select the BigQuery project in which to find or create the target table.
Dataset Select Select the table dataset. The special value, [Environment Default], will use the dataset defined in the environment.
For more information on Google Cloud Datasets, visit the official documentation.
Target Table Select Choose a target table to load.
Warning: This table will be recreated and drop any existing table of the same name upon each run.
Load Columns Multiple Select Choose which columns from your selected target table to load.
Google Storage URL Location String/Select Input, or select via the file path tree, the URL of the Google Storage bucket from which to retrieve files. This follows a format such as gs://<bucket-name>/<path>.
File Format Select Select the type of expected data to load. Some file formats may require additional formatting, which is explained in the GCP Documentation.
Available options are: AVRO, Cloud Datastore Backup, CSV, JSON (New line delimited), ORC, PARQUET (see here for details).
Component properties will change to reflect the choice made here, and Matillion ETL will provide options based on the specific file type.
Write Preference Select Select your write preference:
  • Append to Table: Append an existing table with the loaded data.
  • Overwrite Table: Overwrite an existing table with the loaded data.
  • Write if Empty: Only write loaded data if the target table is empty.
Number of Errors Allows Integer The maximum number of individual parsing errors that cause the whole load to fail. Values up to this will be substituted as null values.This value defaults to 0.
Ignore Unknown Values Select Yes: Accept rows that contain values that do not match the schema. Unknown values are ignored.
Note: Will ignore extra values at the end of a line for CSV files.
No: Omit any rows with invalid values.
Delimiter String Specify the delimiter that separates columns. The default is a comma (,). A [TAB] character can be specified as "\t".
CSV Quoter String Quote character to use to enclose records. Default (field left blank) is double-quote ("). To indicate no quote character at all, use an empty string.
Encoding Select The encoding type to use on the output data. This defaults to UTF-8.
Header rows to skip Integer The number of rows at the top of the file to ignore - defaults to 0.
Allow Quoted Newlines Select Yes: Allow a CSV value to contain a newline character when the value is encased in quotation marks.
No: A new line character, regardless of quotations, is always considered a new row.
Allow jagged rows Select Yes: Missing values are treated as "null" but accepted.
No: Rows with missing data are treated as bad records. Note: A bad record will count toward the "Maximum Errors" count.
Null Marker String The String value which represents the NULL value in the text file.

Example

In this example, we have a table of email data that we wish to back up on a bucket for long-term storage. But we also want to create a copy of the table to transform, leaving the original in tact. One of the many ways to do this is to unload the table to a bucket using the Cloud Storage Unload component, then reload that data into a new table using the Cloud Storage Load component. The job layout is shown below.

The table data is unloaded by the Cloud Storage Unload component and a new table is created using a Create Table component. Now we can look to the Cloud Storage Load properties shown below. Many properties have been automatically set for us and we need only edit a few. It is important to mirror the details with which we unloaded the data - namely a CSV file with a header that should be ignored. We load in all available columns (note that these must be set in the Create Table component!) and point it to the 'Target Table' which will become our copied table.

The job can now be run, unloading the data and then reloading it into our new 'doc_email' table. We can use a Table Input component in a Transformation job to sample the data and confirm that the entire workflow has been as expected.