WRITE_NOS Table Operator Syntax | SQL Statements | Teradata Vantage - 17.05 - WRITE_NOS Syntax - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Advanced SQL Engine
Teradata Database
Release Number
January 2021
English (United States)
Last Update
Write_NOS (
  ON { [database_name.]table_name | (subquery) } 
     [ PARTITION BY column_name [,...] ORDER BY column_name [,...] |
       HASH BY column_name [,...] LOCAL ORDER BY column_name [,...] |
       LOCAL ORDER BY column_name [,...]]
    AUTHORIZATION(' { "Access_ID":"your_access_id",
                      "Access_Key":"your_access_key" } ')
    [MANIFESTFILE('manifest_name') ]
    [COMPRESSION( { 'GZIP' | 'SNAPPY'} ) ]
Name of the table from which data will be written to external storage.
Query that returns data to be written to external storage.
PARTITION BY column_name [,...] ORDER BY column_name [,...]
HASH BY column_name [,...] LOCAL ORDER BY column_name [,...]
LOCAL ORDER BY column_name [,...]
These clauses allow you to control how Vantage sorts and divides the rows of table_name or the rows returned by subquery among the AMPs before these rows are written to external storage. These clauses affect the external storage object names, which reflect the values each stored object contains according to the NAMING option.
  • PARTITON BY invokes WRITE_NOS multiple times on each AMP, once for each partition, and writes at least one file to external storage per partition. If you specify PARTITION BY, the partitioning columns must be included in the ORDER BY list.
  • HASH BY invokes WRITE_NOS only once per AMP, and writes at least one file to external storage for each AMP.
  • Use LOCAL ORDER BY alone if any of the columns that would have been in the PARTITION BY or HASH BY column lists has only a small variety of values, which would hash all the table data to one or just a small number of AMPs, causing data skew. LOCAL ORDER BY minimizes data skew by preventing data from being redistributed based on the partitioning or hashing columns. Instead the data is ordered in place on each AMP before being written to external storage.
You can specify up to 10 columns to partition, hash, or local order by.
You can see how many partitions will be created for a table or subquery before you write to external storage by using a query that groups the results by the partitioning columns. For example:
      GROUP BY column1,column2)
Note the following restrictions on columns used for ORDER BY and LOCAL ORDER BY:
  • Data types are limited to BYTEINT, SMALLINT, INTEGER, BIGINT, DATE, and VARCHAR.
  • VARCHAR columns can only contain alphanumeric and these special characters:
     - _ ! * ' ( ) 
  • VARCHAR columns are limited to 128 characters.
A URI identifying the external storage system in the format
The LOCATION string cannot exceed 2048 characters.
{ "Access_ID":"your_access_id","Access_Key":"your_access_key" } ')
A set of name:value pairs (NVPs) in JSON format that contain access information for the external storage system.
To protect your authorization information, Teradata recommends you use IAM roles, if defined for Amazon S3 repositories, or create a function mapping for WRITE_NOS that includes your authorization credentials. For example:
{ "Access_ID":"your_access_id","Access_Key":"your_access_key" } ');
After defining the function mapping, you can use WRITE_NOS_fm without explicitly passing authorization information instead of using WRITE_NOS, See "CREATE FUNCTION MAPPING" in Teradata Vantage™ - SQL Data Definition Language Syntax and Examples, B035-1144.
Objects created in external storage by WRITE_NOS are written only in Parquet format.
This determines how the objects containing the rows of data are named in the external storage:
  • Discrete naming uses the ordering column values as part of the object names in external storage. For example, if the PARTITION BY clause has ORDER BY dateColumn, intColumn, the discrete form name of the objects written to external storage would include the values for those columns as part of the object name, which would look similar to this:
    2019-03-01 is the value for dateColumn, the first ordering column, and 13 is the value for the second ordering column, intColumn. All rows stored in this external Parquet-formatted object contain those two values.
  • Range naming, the default, includes as part of the object name the range of values included in the partition for each ordering column. For example, using the same ORDER BY as above the object names would look similar to this:
    where 2019-01-01 is the minimum value in that object for the first ordering column, dateColumn, 2019-03-02 is the maximum value for the rows stored in this external Parquet-formatted object. Value 9 is the minimum value for the second ordering column, intColumn, and 10000 is the maximum value for that column.
Specifies the fully qualified path and file name where the manifest file is written. Use the format
/connector/end point/bucket_or_container/prefix/manifest_file_name
For example:
If you do not include the MANIFESTFILE parameter, no manifest file is written.
Writes only a manifest file in external storage.
No actual data objects are written to external storage if you use MANIFESTONLY('TRUE').
You must also use the MANIFESTFILE('manifest_name') option to create a manifest file in external storage.
Use this option to create a new manifest file in the event that a WRITE_NOS operation fails due to a database abort or restart, or when network connectivity issues interrupt and stop a WRITE_NOS operation before all data has been written to external storage.
The manifest is created from the table or query result set that is input to WRITE_NOS. The input must be a list of storage object names and sizes, with one row per object.
The input to WRITE_NOS with MANIFESTONLY can itself incorporate READ_NOS, similar to this, which uses function mappings for WRITE_NOS and READ_NOS:
  (SELECT Location, ObjectLength 
  ) AS d1 )
) AS d;
A query like this can be used if a WRITE_NOS operation fails before it can create a manifest file. The new manifest file created using READ_NOS will reflect all data objects currently in the external storage location, and can aid in determining which data objects resulted from the incomplete WRITE_NOS operation. For more information, see Teradata Vantage™ - Native Object Store Getting Started Guide, B035-1214.
Determines whether an existing manifest file in external storage will be overwritten with a new manifest file that has the same name. If FALSE, the default, WRITE_NOS returns an error if a manifest file exists in external storage that is named identically to the value of MANIFESTFILE.
Determines whether the the ORDER BY and HASH BY columns and their values are written to external storage.
Specifies the maximum output object size in megabytes, where max_object_size is a number between 4 and 16. The default is the value of the DefaultRowGroupSize field in DBS Control. For more information on DBS Control, see Teradata Vantage™ - Database Utilities , B035-1102 .
Determines the compression algorithm used to compress the objects written to external storage.
For Parquet files the compression occurs inside parts of the parquet file instead of for the entire file, so the file extension on external objects remains .parquet.


WRITE_NOS writes the database data to external storage according to the options passed to it, and returns information about the objects it wrote to external storage. The returned values are a table with the following columns:

INTEGER value that identifies the SQL Engine node that contains the data written to the external object.
INTEGER value that identifies the AMP that contains the data written to the external object.
BIGINT value that uniquely identifies the external object to avoid name conflicts in cases where there might otherwise have been multiple objects with the same path and name.
VARCHAR(1024) UNICODE value that is the full object file name in the format:
  • connector
  • endpoint
  • bucket_or_container
  • prefix depends on the value of the NAMING option, discrete or range naming.
  • object_file_name is in the format:
    <Location Path>/[<Discrete Naming or Range Naming>]/object_<Node_ID>_<AMP_ID>_<Sequence>.parquet
For example:
BIGINT value that is the external object size in bytes.
BIGINT value that indicates the number of SQL Engine records in the external object.

Usage Notes

WRITE_NOS will not overwrite data objects in external storage. If a WRITE_NOS operation encounters an object with the exact path and name it is trying to write, it will stop and generate an error.

In this case, the WRITE_NOS operation will stop, return an error, and will not create a manifest file, even if the MANIFESTFILE option was used. The write operation may have written some data objects to the external storage location, and these must be removed manually before attempting to repeat the same WRITE_NOS operation. For information on how to determine the data objects that must be removed from external storage before repeating the same WRITE_NOS operation, see Teradata Vantage™ - Native Object Store Getting Started Guide, B035-1214.