Path Variables as Columns for CSV | Native Object Store ( NOS ) | Teradata Vantage - Using Path Variables as Columns in a View - 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

By creating a view, path expressions (such as $path.$siteno) become columns in the view allowing the user to specify WHERE clauses on those columns without being aware that the underlying table contains complex path expressions.

The names given to the columns in the view are case insensitive. Although shown in mixed case, they can be referenced in SQL queries using any mix of case desired.

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 of the foreign table:
    REPLACE VIEW riverflowview_csv AS (
    SELECT CAST($path.$siteno AS CHAR(10)) TheSite,
    CAST($path.$year AS CHAR(4)) TheYear,
    CAST($path.$month AS CHAR(2)) TheMonth,
    CAST(SUBSTR($path.$day, 1, 2) AS CHAR(2)) TheDay,
    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);