Accessing Path Variables by Creating a Table from Foreign Table | NOS teradataml - Accessing Path Variables by Creating a Table from Foreign Table - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
December 2024
ft:locale
en-US
ft:lastEdition
2025-01-23
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
Product Category
Teradata Vantage

User can access actual columns and path variables by creating a regular table on a SELECT query (Create Table as SELECT, CTAS) with each required column and path variables selected from the foreign table. Each path variable must be typecast to a valid type and then aliased to the appropriate column name. This allows user to access path variables along with Parquet data. It is up to the user on what must be selected in SELECT query passed to "DataFrame.from_query()": columns, attributes, keys from foreign table and path variables.

Example

Create a regular table.

# Let's see an example. Here is how we created a regular table from foreign table.

"""
CREATE TABLE t1lctas AS ( 
SELECT CAST($path.$var1 AS CHAR(10)) Var1,
       CAST($path.$var2 AS CHAR(4)) Var2,
       CAST($path.$var3 AS CHAR(2)) var3,
       CAST($path.$var4 AS CHAR(2)) Var4,
       a, b, c, d, e, f, g, h, i, j
FROM t1l)
WITH DATA
PRIMARY INDEX(a)
"""

Create a DataFrame on the table and display the head of the DataFrame.

# Create a DataFrame on a table.
>>> wrk2dfview = DataFrame("t1lctas")
>>> wrk2dfview.head().to_pandas()
Var1	Var2	var3	Var4	b	c	d	e	f	g	h	i	j
a													
3	csoj_files	t1l.	None	None	30	103	1	CScs	1961-06-05	300.333	19.0	4	10
5	csoj_files	t1l.	None	None	50	105	1	CScs	1961-06-05	200.333	19.0	4	10
6	csoj_files	t1l.	None	None	60	106	1	CScs	1963-02-03	300.333	19.0	4	10
7	csoj_files	t1l.	None	None	70	107	1	CScs	1963-02-03	100.333	19.0	4	10
9	csoj_files	t1l.	None	None	90	109	1	CScs	1963-02-03	300.333	19.0	4	10
10	csoj_files	t1l.	None	None	100	110	1	CScs	1963-02-03	100.333	19.0	4	10
8	csoj_files	t1l.	None	None	80	108	1	CScs	1963-02-03	200.333	19.0	4	10
4	csoj_files	t1l.	None	None	40	104	1	CScs	1961-06-05	100.333	19.0	4	10
2	csoj_files	t1l.	None	None	20	102	1	CScs	1961-06-05	200.333	19.0	4	10
1	csoj_files	t1l.	None	None	10	101	1	CScs	1961-06-05	100.333	19.0	4	10