VOOZH about

URL: https://www.cdata.com/kb/tech/xml-ssis-snowflake.rst

โ‡ฑ Migrating data from XML to Snowflake using CData SSIS Components.


Migrating data from XML to Snowflake using CData SSIS Components.

๐Ÿ‘ Cameron Leblanc
Cameron Leblanc
Senior Technology Evangelist
Easily push XML data to Snowflake using the CData SSIS Tasks for XML and Snowflake.

Snowflake is a leading cloud data warehouse and a popular backbone for enterprise BI, analytics, data management, and governance initiatives. Snowflake offers features such as data sharing, real-time data processing, and secure data storage which makes it a common choice for cloud data consolidation.

The CData SSIS Components enhance SQL Server Integration Services by enabling users to easily import and export data from various sources and destinations.

In this article, we explore the data type mapping considerations when exporting to Snowflake and walk through how to migrate XML data to Snowflake using the CData SSIS Components for XML and Snowflake.

Data Type Mapping

Snowflake Schema CData Schema

NUMBER, DECIMAL, NUMERIC, INT, INTEGER, BIGINT, SMALLINT, TINYINT, BYTEINT

decimal

DOUBLE, FLOAT, FLOAT4, FLOAT8, DOUBLEPRECISION, REAL

real

VARCHAR, CHAR, STRING, TEXT, VARIANT, OBJECT, ARRAY, GEOGRAPHY

varchar

BINARY, VARBINARY

binary

BOOLEAN

bool

DATE

date

DATETIME, TIMESTAMP, TIMESTAMP_LTZ, TIMESTAMP_NTZ, TIMESTAMP_TZ

datetime

TIME

time

Special Considerations

  • Casing: Snowflake enforces an exact case match by default for identifiers, so it is common to run into issues that can be attributed to mismatched casing. Set the IgnoreCase property to True in your CData SSIS Components for Snowflake connection to resolve these issues. This property directly maps to the QUOTED_IDENTIFIERS_IGNORE_CASE property in Snowflake and specifies whether Snowflake will treat identifiers as case-sensitive.
  • Timestamps: Snowflake supports three timestamp types:

    • TIMESTAMP_NTZ: This timestamp stores UTC time with a specified precision. However, all operations are performed in the current session's time zone, controlled by the TIMEZONE session parameter.
    • TIMESTAMP_LTZ: This timestamp stores "wallclock" time with a specified precision. All operations are performed without taking any time zone into account.
    • TIMESTAMP_TZ: This timestamp stores UTC time together with an associated time zone offset. When a time zone isn't provided, the session time zone offset is used.

    By default the CData SSIS Components write timestamps to Snowflake as TIMESTAMP_NTZ unless manually configured.

Prerequisites

Create the project and add components

  1. Open Visual Studio and create a new Integration Services Project. ๐Ÿ‘ Create the SSIS project
  2. Add a new Data Flow Task to the Control Flow screen and open the Data Flow Task.
  3. Add a CData XML Source control and a CData Snowflake Destination control to the data flow task. ๐Ÿ‘ Add the source and destination controls (Salesforce is shown)

Configure the XML source

Follow the steps below to specify properties required to connect to XML.

  1. Double-click the CData XML Source to open the source component editor and add a new connection. ๐Ÿ‘ Open the source component editor (Salesforce is shown)
  2. In the CData XML Connection Manager, configure the connection properties, then test and save the connection.

    Connecting to Local or Cloud-Stored (Box, Google Drive, Amazon S3, SharePoint) XML Files

    CData Drivers let you work with XML files stored locally and stored in cloud storage services like Box, Amazon S3, Google Drive, or SharePoint, right where they are.

    Setting connection properties for local files

    Set the URI property to local folder path.

    Setting connection properties for files stored in Amazon S3

    To connect to XML file(s) within Amazon S3, set the URI property to the URI of the Bucket and Folder where the intended XML files exist. In addition, at least set these properties:

    • AWSAccessKey: AWS Access Key (username)
    • AWSSecretKey: AWS Secret Key

    Setting connection properties for files stored in Box

    To connect to XML file(s) within Box, set the URI property to the URI of the folder that includes the intended XML file(s). Use the OAuth authentication method to connect to Box.

    Dropbox

    To connect to XML file(s) within Dropbox, set the URI proprerty to the URI of the folder that includes the intended XML file(s). Use the OAuth authentication method to connect to Dropbox. Either User Account or Service Account can be used to authenticate.

    SharePoint Online (SOAP)

    To connect to XML file(s) within SharePoint with SOAP Schema, set the URI proprerty to the URI of the document library that includes the intended XML file. Set User, Password, and StorageBaseURL.

    SharePoint Online REST

    To connect to XML file(s) within SharePoint with REST Schema, set the URI proprerty to the URI of the document library that includes the intended XML file. StorageBaseURL is optional. If not set, the driver will use the root drive. OAuth is used to authenticate.

    Google Drive

    To connect to XML file(s) within Google Drive, set the URI property to the URI of the folder that includes the intended XML file(s). Use the OAuth authentication method to connect and set InitiateOAuth to GETANDREFRESH.

    The property is the controlling property over how your data is represented into tables and toggles the following basic configurations.

    • Document (default): Model a top-level, document view of your XML data. The data provider returns nested elements as aggregates of data.
    • FlattenedDocuments: Implicitly join nested documents and their parents into a single table.
    • Relational: Return individual, related tables from hierarchical data. The tables contain a primary key and a foreign key that links to the parent document.

    See the Modeling XML Data chapter for more information on configuring the relational representation. You will also find the sample data used in the following examples. The data includes entries for people, the cars they own, and various maintenance services performed on those cars.

    ๐Ÿ‘ Configure the source connection (Salesforce is shown)
  3. After saving the connection, select "Table or view" and select the table or view to export into Snowflake, then close the CData XML Source Editor. ๐Ÿ‘ Select the table to export (Salesforce is shown)

Configure the Snowflake destination

With the XML Source configured, we can configure the Snowflake connection and map the columns.

  1. Double-click the CData Snowflake Destination to open the destination component editor and add a new connection. ๐Ÿ‘ Open the destination component editor
  2. In the CData Snowflake Connection Manager, configure the connection properties, then test and save the connection.
    • The component supports Snowflake user authentication, federated authentication, and SSL client authentication. To authenticate, set User and Password, and select the authentication method in the AuthScheme property. Starting with accounts created using Snowflakeโ€™s bundle 2024_08 (October 2024), password-based authentication is no longer supported due to security concerns. Instead, use alternative authentication methods such as OAuth or Private Key authentication.

    Other helpful connection properties

    • QueryPassthrough: When this is set to True, queries are passed through directly to Snowflake.
    • ConvertDateTimetoGMT: When this is set to True, the components will convert date-time values to GMT, instead of the local time of the machine.
    • IgnoreCase: A session parameter that specifies whether Snowflake will treat identifiers as case sensitive. Default: false(case is sensitive).
    • BindingType: There are two kinds of binding types: DEFAULT and TEXT. DEFAULT uses the binding type DATE for the Date type, TIME for the Time type, and TIMESTAMP_* for the Timestamp_* type. TEST uses the binding type TEXT for Date, Time, and Timestamp_* types.
    ๐Ÿ‘ Configure the destination connection
  3. After saving the connection, select a table in the Use a Table menu and in the Action menu, select Insert. ๐Ÿ‘ Choose the destination table
  4. On the Column Mappings tab, configure the mappings from the input columns to the destination columns. ๐Ÿ‘ Map the columns (Salesforce is shown)

Run the project

You can now run the project. After the SSIS Task has finished executing, data from your SQL table will be exported to the chosen table.

Ready to get started?

Download a free trial of the XML SSIS Component to get started:

 Download Now

Learn more:

๐Ÿ‘ XML Documents Icon
XML SSIS Components

Powerful SSIS Source & Destination Components that allow you to easily connect SQL Server with XML data stores through SSIS Workflows.

Use the XML Data Flow Components to synchronize with XML documents. Perfect for data synchronization, local back-ups, workflow automation, and more!