Comment on page

Amazon S3

This page describes the job options for ingesting data from Amazon S3.


CREATE [SYNC] JOB <job_name>
[{ job_options }]
[{ source_options }]
INTO { <table_identifier>
| SNOWFLAKE <connection_name>.<schema_name>.<table_name> }
[ WITH EXPECTATION <exp_name> EXPECT <sql_predicate> ON VIOLATION { DROP | WARN } ];

Jump to

Job options

The following properties can be configured when ingesting data from Amazon S3.
To quickly and efficiently find data in Amazon S3, SQLake needs to list the files in the specified bucket and prefixes. SQLake utilizes the folder structure and naming, i.e. partitions, to optimize reading data before it is processed.
When reading events, SQLake organizes them on a timeline that it uses to synchronize between jobs to ensure data is joined and aggregated correctly. Therefore, storing raw data using date-formatted partitions such as /bucket/data/2022/11/01/, enables SQLake to optimize and speed up ingestion.
To better understand how SQLake reads and processes data using date partitions, see Working with date patterns.
[ COLUMN_TRANSFORMATIONS = (<column> = <expression>, ...) ]
[ COMMENT = '<comment>' ]
[ COMMIT_INTERVAL = <integer> { MINUTE[S] | HOUR[S] | DAY[S] } ]
[ COMPUTE_CLUSTER = <cluster_identifier> ]
| XML } ]
| KCL } ]
[ DATE_PATTERN = '<date_pattern>' ]
[ DEDUPLICATE_WITH = ( {COLUMNS = (<col>, ...) | COLUMN = <col>}, WINDOW = <integer> { MINUTE[S] | HOUR[S] | DAY[S] } ]
[ END_AT = { NOW | <timestamp> } ]
[ EXCLUDE_COLUMNS = ( <col>, ...) ]
[ FILE_PATTERN = '<pattern>' ]
[ FILE_SUFFIX = '<suffix>' ]
[ INITIAL_LOAD_PATTERN = '<pattern>' ]
[ INITIAL_LOAD_PREFIX = '<prefix>' ]
[ MAX_DELAY = <integer> { MINUTE[S] | HOUR[S] | DAY[S] } ]
[ RUN_PARALLELISM = <integer> ]
[ SQS_KMS_KEY = '<key_name>' ]
[ SQS_QUEUE_NAME = '<queue_name>' ]
[ START_FROM = { NOW | BEGINNING | <timestamp> } ]

Jump to

Amazon S3 job options:
General job options:
See also:


Type: <integer> { MINUTE[S] | HOUR[S] | DAY[S] }
Default: 1 MINUTE
(Optional) Defines how often the job will load and commit data to the target in a direct ingestion job. This interval must be divisible by the number of hours in a day.


Default: AUTO
(Optional) The compression of the source.

CONTENT_TYPE — editable

Default: AUTO
(Optional) The file format of the content being read.
Note that AUTO only works when reading Avro, JSON, or Parquet.
To configure additional options for certain content types, see: Content type options.


Type: text
(Optional) The date pattern of the partitions on the Amazon S3 bucket to read from. SQLake supports reading from buckets partitioned up to the minute.
Example: 'yyyy/MM/dd/HH/mm'
For more options, see: Java SimpleDateFormat
When you set a DATE_PATTERN, SQLake uses the date in the folder path to understand when new files are added. The date in the path is used to process data in order of arrival, as well as set the $source_time and $event_time system columns used to keep jobs synchronized. If files are added to a folder named with a future date, these files will not be ingested until that date becomes the present.
If you don’t set a DATE_PATTERN, SQLake will list and ingest files in the ingest job’s BUCKET and PREFIX location as soon as they are discovered. Historical data will also be processed as soon as it is added and discovered by SQLake.
To discover new files, when a DATE_PATTERN is not set, SQLake lists the top-level prefix and performs a diff to detect newly added files. Subsequently, it lists the paths adjacent to these new files with the assumption that if a file was added here, others will be as well. This process is performed at regular intervals to ensure files are not missed.
For buckets with few files and predictable changes, this works well. However, for buckets with many changes across millions of files and hundreds of prefixes, the scanning and diffing process may result in ingestion and processing delay. To optimize this process, consider setting the job’s DELETE_FILES_AFTER_LOAD property to TRUE. This moves ingested files to another staging location, leaving the source folder empty, and making it easier and faster for SQLake to discover new files. Be aware that configuring SQLake to move ingested files could impact other systems if they depend on the same raw files.
To troubleshoot jobs that ingest data, you can query the task execution system table and inspect whether 0 bytes of data have been read in the “ingest data” stage, or SQLake is throwing parse errors in the “parse data” stage. In the case that 0 bytes have been read, it means that your job is configured correctly, but there is no new data. In the case where you see parse errors, you can narrow it down to either a misconfiguration of the job or bad data.


Values: ( {COLUMNS = (, ...) | COLUMN = }, WINDOW = { MINUTE[S] | HOUR[S] | DAY[S] } )
(Optional) You can use DEDUPLICATE_WITH to prevent duplicate rows arriving in your target. One or more columns can be supplied in the column list to act as a key so that all events within the timeframe specified in the WINDOW value are deduplicated.
For example, if you have a third-party application that sends the same event multiple times a day, you can define one or more columns as the key and set the timeframe to be 1 DAY. Upsolver will exclude all duplicate events that arrive within the day, ensuring your target only receives unique events.
Note that if you have multiple jobs writing to a table in your lake, duplicate rows can be generated, even when you include this option.


Type: boolean
Default: false
(Optional) When true, files are deleted from the storage source once they have been ingested into the target location within your metastore.
This allows Upsolver to discover new files immediately, regardless of how many files are in the source, or what file names and patterns are used.


Type: text
Default: ''
(Optional) Only files that match the provided regex pattern are loaded.
Use this option to filter out irrelevant data. For example, you could filter by a suffix to only keep .parquet files in a folder that may have some additional files that should not be ingested.


Type: text
(Optional) This option is only applicable when USE_SQS_NOTIFICATIONS is set to true. It controls which file suffixes S3 will publish notifications for.


Type: text
(Optional) Any file matching this regex pattern is immediately loaded when the job is run.
This loads data separately from the date pattern and is primarily used in CDC use cases, where you load some initial files named LOAD00001, LOAD00002, etc. After that, all the data has a date pattern in the file name.


Type: text
(Optional) Any file matching this prefix is immediately loaded when the job is run.


Value: <integer> { MINUTE[S] | HOUR[S] | DAY[S] }
Default: 1 DAY
(Optional) Configures how far back to check for new files. The larger this is, the more list operations are used.


Type: integer
Default: 1
(Optional) The number of parser jobs to run in parallel per minute.


Type: Boolean
Default: false
(Optional) If data is expected to arrive in the source at a later point in time, set this value to true.
This option instructs Upsolver to ignore all validations to allow you to create a job that reads from a source that currently has no data.


(Optional) Use this option if data is expected to arrive in the source at a later point in time.
This option tells Upsolver to ignore specific validations to allow you to create a job that reads from a source that currently has no data.


Type: text
(Optional) Specifies the KMS key to use for reading from the SQS queue. This is only required if the SQS queue is set up with encryption.


Type: text
(Optional) If set, Upsolver will read from this queue instead of creating a new queue and setting up notification settings. Use this option when you already have a notification queue or need to use an existing queue since AWS can only publish notifications to a single target. A common pattern is to publish to SNS and then forward from SNS to SQS.


Values: { NOW | BEGINNING | <timestamp> }
(Optional) Configures the time to start ingesting data. Files before the specified time are ignored. Timestamps should be in the UTC time format.
When a DATE_PATTERN is not specified, configuring this option is not allowed. By default, all available data is ingested.
If the DATE_PATTERN is not lexicographically ordered, then this option cannot be set to BEGINNING.


Type: Boolean
Default: false
(Optional) When enabled, Upsolver will use SQS notifications sent by the S3 bucket to discover new files. This is particularly useful when the data in the directory being read doesn't have a predictable pattern that can be used to discover files efficiently. If the SQS_QUEUE_NAME isn't set explicitly Upsolver will create an SQS queue and set up bucket notifications to send messages to the queue.
Note: Setting up the queue and notifications requires the appropriate permissions in AWS. In addition S3 bucket notifications are limited to a single target per prefix + suffix combination. If you already have notifications set up for the required files you will need to provide the queue to use manually, or remove the existing notification settings.

Working with date patterns

Before you create your landing zone where raw data will be staged for SQLake to ingest, you need to be aware of a couple of things:
  1. 1.
    Date values should be lexicographically ordered and include a leading zero when applicable. For example, use /2022/02/04 for February 4th 2022, over /22/2/4.
  2. 2.
    Avoid including a dynamically changing prefix, like application ID or job cluster ID, as the first part of your prefix. If you need to include it, add it at the end. For example, use /2022/02/04/X34TFA2 instead of /X34TFA2/2022/02/04.
To ingest date-partitioned Amazon S3 data, you can configure the DATE_PATTERN property of your ingestion job. For Apache Hive partitions, the value is prefixed with a keyword representing its meaning. For example, /year=2022/month=02/day=04/. To support this format, you include the prefixes in the DATE_PATTERN property surrounded by two single quotes (not a double quote).
Using the above example, the DATE_PATTERN will be ’’year=’’yyyy’’/month=’’MM’’/day=’’dd. As you can see, the string literals in the pattern, like ‘’year=’’ and ‘’month=’’ are wrapped in two single quote characters, not double quotes.
If there is a single quote in your folder path that needs to be represented in the path literal, you need to surround it with two single quotes. For example, year(‘0’)=2000 would be represented as ’’’year(’’’’0’’’’)=’’yyyy/’. This could be confusing, so ensure you’re quoting the string literal parts of the pattern and not the date value patterns.
Note that when there is no date pattern defined, you cannot define a time to start ingestion; all available data is ingested by default.

Source options


Type: text
The location to read files from, as a full Amazon S3 URI.


Ingest data into the data lake

The example below creates a sync job to ingest data from Amazon S3 into a staging table that has been created in the data lake. The CONTENT_TYPE option specifies that the data to be ingested is in JSON format.
After the data has been ingested into the staging table, you can create a transformation job to load the data into your target.
CREATE SYNC JOB load_orders_raw_data_from_s3
AS COPY FROM S3 upsolver_s3_samples LOCATION = 's3://upsolver-samples/orders/'
INTO default_glue_catalog.upsolver_samples.orders_raw_data;
Create a job to ingest data from Amazon S3 to a table in the data lake.

Ingest data directly into Snowflake

Data can be ingested directly to Snowflake, removing the need to create staging tables in the lake and write additional transformation jobs to load the data. Ingestion job options provide numerous functions to enable transformations and data quality observability, ensuring that your data lands in the target in the required state, regardless of the source.
In the following example, a sync job is created to ingest data from Amazon S3 directly to Snowflake, using transformations and expectations to ensure the data meets the required standards when it lands in the target table.
The DEDUPLICATE_WITH option tells the job to ensure that duplicate events arriving within an hour of each other are not duplicated on the target. The job uses the orderid column to uniquely identify duplicates. The UPPER string function is applied to the ordertype column using the COLUMN_TRANSFORMATIONS option so that all values in this column land in the target in upper case, and not in mixed case.
Two expectations have been applied to this job: the first, exp_orderid, tells the job to drop any rows from the stream that have a NULL value for the orderid. Rows that violate this expectation do not reach the target but are counted in the job monitoring tables. The second expectation, exp_shippinginfo, checks that the shipping method is either express or regular. If this condition is violated, the rows are loaded into the target, and the job monitoring tables count each row that raises a warning so you can observe your data quality and take necessary action.
CREATE SYNC JOB ingest_s3_to_snowflake
COMMENT = 'Load orders into Snowflake'
DEDUPLICATE_WITH = (COLUMNS = (orderid), WINDOW = 1 hour)
COLUMN_TRANSFORMATIONS = (ordertype = UPPER(ordertype))
AS COPY FROM S3 upsolver_s3_samples LOCATION = 's3://upsolver-samples/orders/'
INTO SNOWFLAKE my_snowflake_connection.demo.orders_transformed
WITH EXPECTATION exp_shipping EXPECT shippinginfo.method IN ('express', 'regular') ON VIOLATION WARN;
Create a job to ingest data directly from Amazon S3 to Snowflake, using transformations and expectations.
For more information about data observability, see Managing data quality with expectations.