Path Filtering for CSV | Native Object Store ( NOS ) | Teradata Vantage - 17.10 - Querying a Foreign Table with Path Filtering - 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)

All foreign tables have a generic PATHPATTERN; for example, PATHPATTERN('$Var1/$Var2/$Var3/$Var4/$Var5/$Var6/$Var7/$Var8/$Var9/$Var10/$Var11').

To make path filtering in a query easier, explicitly specify a PATHPATTERN with meaningful names when you create the foreign table. For example, to match the path names selected in the river flow example, use ('$data/$siteno/$year/$month/$day'). PATHPATTERNs are useful for limiting results, instead of returning all the objects.

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. Use path filtering to narrow down search results. To see the data for a site number on a particular date, query the path attributes:
    SELECT TOP 2 *
    FROM riverflow_csv_pathfilter
    WHERE $PATH.$year = 2018
    AND $PATH.$month = 07
    AND $PATH.$day = '01.csv'
    AND $PATH.$siteno = 09380000;

    The $PATH.$day variable represents the actual object in the path segment name ( siteno / year / month / day). As such, it often has a file extension as part of the name, as shown in the example.

    Your result will be similar to the following:

         Location  /S3/
             Temp   11.6
             Flow   10000
          site_no      9380000
         datetime  2018-07-01 00:15
      Conductance     666
    Precipitation    .00
       GageHeight    8.65
         Location  /S3/
             Temp   11.6
             Flow   10000
          site_no      9380000
         datetime  2018-07-01 00:00
      Conductance     662
    Precipitation    .00
       GageHeight    8.65

    The output is displayed vertically for readability.

    Note that the more specific you are with path filtering, the more selective are the results, potentially saving processing time and external storage access costs.