SnowConvert AI - Teradata - MLOAD¶
Translation references to convert Teradata MLOAD files to Snowflake Scripting.
Description¶
The Teradata MultiLoad (MLoad) utility is designed for efficient batch maintenance of large databases, offering a command-driven approach for fast, high-volume data loading operations.
SnowConvert AI translates MLoad scripts into Snowflake Scripting using the COPY INTO command with staged files.
Translation Structure¶
The generated output is organized into two distinct sections due to Snowflake’s execution model:
1. Stage and file upload (outside EXECUTE IMMEDIATE)
The CREATE TEMPORARY STAGE and PUT commands are placed before the EXECUTE IMMEDIATE block.
Why? The PUT command is a client-side operation—it transfers files from your local machine to a Snowflake stage. This file transfer happens on your machine, not on the Snowflake server. As a result, PUT can only run through SnowSQL (the command-line client) and cannot execute inside stored procedures, EXECUTE IMMEDIATE blocks, or the Snowflake web UI.
2. Data loading (inside EXECUTE IMMEDIATE)
The COPY INTO statement and any additional logic are wrapped in an EXECUTE IMMEDIATE block with exception handling. This separation ensures the file upload completes first, and then the server-side data loading runs with proper error handling.
Supported Commands¶
.LOGTABLE¶
The .LOGTABLE command stores checkpoint and restart information for MLoad sessions. Snowflake manages checkpointing internally, so this command is removed.
Since MLoad’s IMPORT command is translated to Snowflake’s COPY INTO statement, you can use the COPY_HISTORY table function to monitor and track your data loading operations. This function queries the loading history for a specified table within the last 14 days, returning details such as file names, load times, row counts, error messages, and statuses. For longer retention (up to 365 days), use the COPY_HISTORY view in the Account Usage schema.
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
.SET Variables¶
The .SET command defines variables referenced with &VARIABLE throughout the script. These are translated to Snowflake Scripting variables using DECLARE.
Type Inference¶
Snowflake automatically infers the variable type from the assigned value, so explicit type declarations are not required in most cases. However, when the value involves concatenation (using the || operator), the STRING type must be explicitly declared.
MLoad Source |
Snowflake Translation |
|---|---|
|
|
|
|
|
|
|
|
|
|
Bind Variables¶
Since the .SET command is translated to DECLARE variables in Snowflake Scripting, these variables must be referenced using bind variable syntax when used within SQL statements. This is done by prefixing the variable name with a colon (:), which allows for dynamic substitution of values at execution time.
Teradata MLoad¶
Snowflake Scripting¶
Using Variables as Object Identifiers¶
When a variable represents the name of a database object (table, schema, etc.), the IDENTIFIER function must be used. This function tells Snowflake to interpret the variable’s value as an object identifier rather than a string literal. The function ensures the variable is treated strictly as an identifier, reducing security risks.
Important: The IDENTIFIER() function does not support concatenation expressions directly. You cannot write IDENTIFIER(:schema || '.' || :table). To handle concatenated object names, an intermediate variable with the sc_ prefix (SnowConvert) is generated to hold the pre-computed concatenation result.
Teradata MLoad¶
Snowflake Scripting¶
Variable Concatenation¶
MLoad supports concatenating variables using the dot (.) operator. A single dot joins values directly, while a double dot inserts a literal dot separator:
MLoad Pattern |
Result |
Snowflake Translation |
|---|---|---|
|
|
|
|
|
|
|
|
|
When concatenation is used within a string literal, embedded variables are extracted and concatenated:
MLoad Pattern |
Snowflake Translation |
|---|---|
|
|
|
|
|
|
Variable Reassignment¶
When a variable is reassigned after its initial declaration, the reassignment is placed inside the BEGIN block.
Teradata MLoad¶
Snowflake Scripting¶
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
.BEGIN IMPORT MLOAD / .END MLOAD¶
These commands define the scope of an MLoad import operation. They are removed because Snowflake’s COPY INTO command is atomic and handles scope internally.
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
.LOGOFF¶
The .LOGOFF command terminates the MLoad session. This is not applicable in Snowflake and is removed from the output.
Data Import Translation¶
VARTEXT Format (Delimited Files)¶
The VARTEXT format loads delimited files. If no delimiter is specified, the default is pipe (|).
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
TEXT/UNFORMAT Format (Fixed-Width Files)¶
The TEXT and UNFORMAT formats load fixed-width files. Field positions can use:
Asterisk (
*): Automatic position calculation based on field lengthExplicit number: Specific byte position in the record
Fields are extracted using the SUBSTRING function.
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
Note
.FILLER fields are excluded from the SELECT statement.
Field Options¶
Trim Options¶
The .FIELD command supports options for trimming data:
MLoad Option |
Snowflake Function |
|---|---|
|
|
|
|
|
|
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
Import Options¶
FROM Clause (Skip Rows)¶
The FROM n clause specifies to start reading from row n. This translates to SKIP_HEADER = n - 1.
MLoad |
Snowflake |
|---|---|
|
|
|
|
|
|
WHERE Condition¶
The WHERE clause filters records during import. Since Snowflake’s COPY INTO only supports SELECT ... FROM ... queries (without WHERE), the translation uses a staging table pattern:
Create a temporary staging table with the same structure as the target table
Load all data into the staging table using
COPY INTOInsert filtered records from the staging table into the target table using
INSERT INTO ... SELECT ... WHEREDrop the staging table
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
File Path Handling¶
MLoad’s .IMPORT INFILE path is translated to Snowflake’s PUT command, which requires the file:// protocol prefix. The file is uploaded to a stage (@sc_import_stage) and then referenced in the COPY INTO statement.
Bash Variables in Paths¶
Bash variables (${VAR}) are converted to SnowSQL variable substitution syntax (&{VAR}). These require running the script through SnowSQL with variable substitution enabled.
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
Local Variables in Paths (Not Supported)¶
Local MLoad variables (&VAR) are not supported in file paths for PUT and COPY INTO statements. An EWI marker is generated to indicate manual resolution is required.
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
Quoted Paths¶
Paths enclosed in single quotes ('...') are handled differently. The COPY INTO statement uses the FILES clause to specify the file name instead of appending it to the stage path.
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
Windows Path Conversion¶
Quoted paths with Windows backslashes (\) are automatically converted to forward slashes (/) for compatibility with Snowflake’s PUT command.
MLoad Path |
Snowflake Output |
|---|---|
|
|
Multiple Imports¶
When a script contains multiple .IMPORT commands:
The
CREATE TEMPORARY STAGEis executed once at the beginningAll
PUTcommands for all imports are grouped together before theEXECUTE IMMEDIATEblockEach import is translated to a separate
BEGIN...ENDblock inside the script
Complete Example with Different Formats¶
The following example demonstrates two imports with different formats:
First import:
VARTEXTformat (CSV with comma delimiter)Second import:
TEXTformat (fixed-width usingSUBSTRING)
Sample Source Patterns¶
Teradata MLoad¶
Snowflake Scripting¶
Translation Requirements¶
For the .IMPORT command to be fully translated, all of the following conditions must be met. See Known Limitations for unsupported features.
Required Components¶
Component |
Requirement |
Error if Missing |
|---|---|---|
|
Must be defined before the |
|
|
Must contain at least one |
|
Supported Formats¶
The following file formats are fully translated to Snowflake’s COPY INTO command:
MLoad Format |
Description |
Snowflake FILE_FORMAT |
|---|---|---|
|
Delimited file with separator |
|
|
Delimited file with default pipe separator |
|
|
Fixed-width positional file |
|
|
Fixed-width positional file (binary-safe) |
|
Supported Layout Definitions¶
Field definitions in .LAYOUT are translated based on the format type:
MLoad Definition |
Use Case |
Snowflake Translation |
|---|---|---|
|
Delimited files (VARTEXT) - auto position |
|
|
Fixed-width files (TEXT/UNFORMAT) - explicit position |
|
|
Skip unused bytes in fixed-width files |
Excluded from SELECT |
Supported DML Statements¶
The DML statement inside .DML LABEL determines how data is loaded:
MLoad DML |
Description |
Snowflake Translation |
|---|---|---|
|
Insert new records |
|
Supported Field Modifiers¶
Field modifiers for trimming whitespace are translated to Snowflake string functions:
MLoad Modifier |
Description |
Snowflake Function |
|---|---|---|
|
Remove leading spaces |
|
|
Remove trailing nulls/spaces |
|
|
Remove both leading and trailing |
|
Supported IMPORT Clauses¶
The following .IMPORT options are translated to equivalent Snowflake functionality:
MLoad Clause |
Description |
Snowflake Translation |
|---|---|---|
|
Start reading from row n (skip header rows) |
|
|
Filter records during import |
Uses staging table pattern (see WHERE Condition) |
|
Continue on errors |
|
Known Limitations¶
The following MLoad features are not currently supported and will generate an EWI marker (SSC-EWI-TD0094) indicating manual resolution is required:
Unsupported Formats¶
Format |
EWI Message |
|---|---|
|
|
|
|
Unsupported Layout Types¶
Layout Type |
EWI Message |
|---|---|
|
|
Unsupported DML Statements in IMPORT¶
The following DML statements are not supported when used within a .DML LABEL applied by an .IMPORT command. Standalone DML statements outside of the import context are translated correctly.
DML Statement in |
EWI Message |
|---|---|
|
|
|
|
Missing Required Components¶
Missing Component |
EWI Message |
|---|---|
|
|
|
|