Example of foreign table definition with path pattern | Teradata Vantage - 17.10 - Example: Creating Foreign Table with PATHPATTERN - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1144-171K
Language
English (United States)

This example creates a foreign table by specifying the table_name (sensordata), LOCATION, and PATHPATTERN. In this example, LOCATION specifies levels below the bucket (data and logs), PATHPATTERN specifies several more, and the external file has JSON-formatted data.

CREATE FOREIGN TABLE Statement

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;