Azure SQL - Bulk Load

In this article

 

Overview

You can use this Snap to perform a bulk load operation from the input view document stream to the target table by using SQLServerBulkCopy API. It uses a memory buffer to send records to the target table instead of a temporary CSV file. The Batch size and Bulk copy timeout values can be used to tune the performance and memory used.

This Snap supports a dot (.) as a separator for milliseconds in date and time formats, which helps in handling date and time data types and functions when working with SQL Server (Transact-SQL). Learn more: Date and Time Data Types and Functions - SQL Server (Transact-SQL)

azure-sql-bulk-load-overview.png

 

Snap Type

The Azure SQL Bulk Load Snap is a Write-type Snap that performs a bulk load operation.

Prerequisites

The Azure SQL database account requires the SQL Server JDBC driver. Version 4.1 and older do not support the SQLServerBulkCopy API.

Support for Ultra Pipelines

Does not support Ultra Pipelines

Limitation

  • Microsoft does not support the DateTime data type when writing to Azure Data Warehouse. As a workaround, change the data type from DateTime to varchar when writing to Azure Data Warehouse. Note that if the table does not exist in the database, enabling the Create table if not present property automatically converts all DateTime fields to varchar fields. For more information on this known issue, see Known Limitations for the batch insert operation

  • You cannot modify certain columns in Azure SQL because they might either be computed columns or the result of a UNION operator, such as "InventoryValue."

  • The Azure Bulk Load Snap supports the money and smallmoney data types only within the following specific ranges:

Data Type

Range

Data Type

Range

money

-922,337,203,685,477.5808 to 922,337,203,685,477.5807

smallmoney

-214,748.3648 to 214,748.3647

When you insert a value beyond the specific range, the Snap does not fail but inserts incorrect values. For instance, see the table below for the incorrect inserted values against the specific value:

Data Type

 When you update

Bulk Load is updated to

smallmoney

-214758.3648

-214738.3649

money

922337203685487.5808

922337203685467.5808



smallmoney

214758.3647

214738.3648

money

922337203685487.5807

-922337203685467.5809

This issue is caused by MSSQL-JDBC dependency from Microsoft®, that converts small-money/money values to int/long values. SnapLogic® has reported a bug in Microsoft®MSSQL-JDBC GitHub repository. You can track the issue here.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

 

  • Min: 0

  • Max: 2

Mapper

  • All input documents must contain map data with a key-value pair. All keys must be spelled the same as in columns in the target table (case-sensitive). Input documents must not contain any data other than data to be bulk-loaded.

  • All input documents must have the same keys. If the number of keys is smaller than the number of columns in the target table, the Snap fills missing keys with null values. If key names in the input document is different from column names, Mapper Snap can be used to map key names to column names.

Output

Document

  • Min: 0

  • Max: 1

JSON Formatter

  • The input document stream is converted to multiple batches, which are bulk-loaded to the target table by using SQLServerBulkCopy API. The Snap converts the input data values according to the corresponding SQL Server column data types to Java class objects which SQLServerBulkCopy accepts.

  • Outputs the bulk-load result in a key-value pair, for example:

{"status" : "34687 records loaded"}
If no record is loaded because of errors, no output document is produced.

When accessing a column name that contains specific characters as supported by Azure SQL, like $, #, @, etc., such field names should be enclosed in the square brackets.

Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter while running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution: Stops the current pipeline execution when the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the rest of the records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap Settings

  • Asterisk (*): Indicates a mandatory field.

  • Suggestion icon (): Indicates a list that is dynamically populated based on the configuration.

  • Expression icon (): Indicates whether the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.

  • Add icon (): Indicates that you can add fields in the field set.

  • Remove icon (): Indicates that you can remove fields from the field set.