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

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

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
jjn1567647976698.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1214
lifecycle
previous
Product Category
Software
Teradata Vantage

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.