Path Variables as Columns for CSV | Native Object Store ( NOS ) | Teradata Vantage - 17.10 - Using Path Variables as Columns in a View - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - Native Object Store Getting Started Guide

Advanced SQL Engine
Teradata Database
Release Number
Release Date
July 2021
Content Type
Programming Reference
Publication ID
English (United States)

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_pathfilter: See Filtering Using a Column Within the Data Set.
  3. Create the view of the foreign table:
    REPLACE VIEW riverflowview_csv AS (
    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,
    FROM riverflow_csv_pathfilter);
  4. Query the view:
    SELECT TOP 2 * FROM riverflowview_csv;

    Your result will be similar to the following:

    TheSite  TheYear TheMonth TheDay Flow  GageHeight  Precipitation  Temp  Conductance 
    -------- ------- -------- ------ ----- ----------- -------------  ----  ----------- 
    09380000    2018       07     18 17500	  10.21           .00  11.0         670
    09380000    2018       07     24 17700	  10.25           .00  10.9         670

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