Example of foreign table definition with path pattern | Teradata Vantage - 17.00 - Example: Creating a Foreign Table with a Pathpattern Definition - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Release Date
September 2020
Content Type
Programming Reference
Publication ID
B035-1144-170K
Language
English (United States)

This example creates the foreign table sensordata with the PATHPATTERN option set to:

$Var1/$Var2/$var3/$Var4/$date

Although the LOCATION clause only contains two levels (data and logs) below the bucket, the path pattern specifies several other levels. The LOCATION string only identifies a key prefix and there can be many levels below that in the actual data set being examined. Also, the logs entry in the LOCATION string can also include a longer name, such as, logsdaily.

CREATE MULTISET FOREIGN TABLE sensordata (
    Location VARCHAR(2048) CHARACTER SET UNICODE CASESPECIFIC,  
    Payload JSON(8388096) INLINE LENGTH 32000 CHARACTER SET UNICODE) 
USING (   
    LOCATION ('/S3/YOUR-BUCKET.s3.amazonaws.com/data/logs')   
    PATHPATTERN ('$Var1/$Var2/$var3/$Var4/$date') 
)   
NO PRIMARY INDEX;