Basic Foreign Table View for CSV | Native Object Store ( NOS ) | Teradata Vantage - Creating a Basic View - Advanced SQL Engine - Teradata Database

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

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

CSV payload records are imported as VARCHAR. Creating a view allows you to:

  • CAST the payload fields to an appropriate data type.
  • Rename the header fields using case insensitive naming. Although the example shows the headers in mixed case, you can use whatever case you want in queries.

The examples use a sample river flow data set. To use your own data, replace the table and column names, and authorization object. See Variable Substitutions for Examples for the credentials and location values for the sample data set.

  1. To run NOS-related commands, log on to the database as a user with the required privileges.
  2. If it does not exist, create the foreign table or ask your database administrator to create the foreign table called riverflow_csv_path: See Filtering on the Payload Column of a Foreign Table.
  3. Create the view on the foreign table:
    CREATE VIEW riverflowview_csv AS (
    SELECT
    CAST(payload..Flow AS FLOAT) ( FORMAT '-ZZZZ9.99') Flow,
    CAST(payload..GageHeight AS FLOAT) ( FORMAT '-ZZZ9.99') GageHeight1,
    CAST(payload..Precipitation AS FLOAT) ( FORMAT '-ZZZ9.99') Precipitation,
    CAST(payload..Temp AS FLOAT) ( FORMAT '-ZZZ9.99') Temperature,
    CAST(payload..Velocity AS FLOAT) ( FORMAT '-ZZZ9.99') Velocity,
    CAST(payload..BatteryVoltage AS FLOAT) ( FORMAT '-ZZZ9.99') BatteryVoltage,
    CAST(payload..GageHeight2 AS FLOAT) ( FORMAT '-ZZZ9.99') GageHeight2
    FROM riverflow_csv_path );
    
  4. Query the view:
    SELECT TOP 2 * FROM riverflowview_csv;

    Your result will be similar to the following:

    Flow   GageHeight1 Precipitation Temperature Velocity BatteryVoltage GageHeight2
    ------ ----------- ------------- ----------- -------- -------------- -----------
    186.00        2.05             ?           ?        ?              ?        2.05
    232.00        2.16          0.00           ?        ?              ?        2.16
    

    Columns with missing attributes return NULLs when the record does not contain the attribute.