See If Your CSV Object Has a Header Row | Native Object Store | Teradata Vantage - 17.05 - Previewing Data Using READ_NOS - Teradata Database

Teradata Vantageā„¢ - Native Object Store Getting Started Guide

prodname
Advanced SQL Engine
Teradata Database
vrm_release
17.05
created_date
January 2021
category
Programming Reference
featnum
B035-1214-175K

To understand the contents of external data, sample some rows using the READ_NOS table operator.

In the following example, you determine if your CSV object has a header.

The example reads all the records in a CSV object and assumes the first record in the object is the header. Examine the output to validate if the object contains text that looks like column headings, instead of the values of the attributes. Even though the actual data contains only one record with column headings, READ_NOS repeats the column heading for each record in the data when it produces the output.

Teradata inserts what is assumed to be the header into every subsequent data record when the data is imported. In the example, the part that was prepended to each row is text and appears to be a header row; therefore, the external data in this location has a header row of Flow, site_no, datetime, Conductance, Precipitation, and GageHeight.

The examples and results show a sample river flow data set. To use your own data, replace the table and column names, and authorization object.

  1. To run NOS-related commands, log on to the database as a user with the required privileges.
  2. Run the following:
    SELECT TOP 2 payload FROM READ_NOS_FM (
    ON ( SELECT CAST( NULL AS DATASET STORAGE FORMAT CSV ) )
    USING
    LOCATION('YOUR-STORAGE-ACCOUNT')
    RETURNTYPE('NOSREAD_RECORD')
    ) AS D;

    See Variable Substitutions for Examples for the credentials and location values for the sample river flow data set.

    Your result will be similar to the following:

    Payload
    ---------------------------------------------------------------------------------
    Temp,Flow,site_no,datetime,Conductance,Precipitation,GageHeight 11.4,11400,09380000,2018-07-02 00:00,654,0.00,8.97
    Temp,Flow,site_no,datetime,Conductance,Precipitation,GageHeight 10.6,17600,09380000,2018-07-03 00:00,674,0.00,10.23

    Note that the header is repeated in every record. You can use the column headings to build the foreign table.

    If your CSV object does not have a header, use HEADER('false') in the USING clause to indicate this.