ONNXPredict Example: Input Table Read from NOS - Teradata Vantage

Teradata Vantageā„¢ - Bring Your Own Model User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
Lake
VMware
Product
Teradata Vantage
Release Number
5.0
Published
October 2023
Language
English (United States)
Last Update
2024-04-06
dita:mapPath
fee1607120608274.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
fee1607120608274
SELECT * FROM TD_mldb.ONNXPredict(
ON (select top 10 
	cast(payload..wine_id as INTEGER) wine_id, 
	cast(payload..winetype as VARCHAR(10)) winetype, 
	cast(payload..total_sulfur_dioxide as SMALLINT) total_sulfur_dioxide, 		
	cast(payload..free_sulfur_dioxide as BIGINT) free_sulfur_dioxide, 	
	cast(payload..fixed_acidity as DECIMAL(8,2)) fixed_acidity, 	
	cast(payload..volatile_acidity as FLOAT) volatile_acidity, 
	cast(payload..alcohol as FLOAT) alcohol, 
	cast(payload..citric_acid as NUMBER(5,1)) citric_acid, 
	cast(payload..residual_sugar as NUMBER(,3)) residual_sugar, 
	cast(payload..quality as NUMBER) quality, 
	cast(payload..chlorides as FLOAT) chlorides, 
	cast(payload..density as BYTEINT) density, 
	cast(payload..pH as INTEGER) pH, 
	cast(payload..sulphates as DECIMAL(15,1)) sulphates, 
	cast(payload..grapes as VARCHAR(50)) grapes, 
	cast(payload..BestDateForDrink as TIMESTAMP(6)) BestDateForDrink, 
	cast(payload..type1 as INTEGER) type1 
	from readnos_sqlefnmpng(
		ON (select * from indata_wines)
		USING
			LOCATION('/s3/s3.amazonaws.com/nosfs-pittesting-bucket/byom-test/load_winesTest_1_Test.csv')
			ROWFORMAT('{"field_delimiter":"|","record_delimiter":"\n","character_set":"LATIN"}')) as t order by 1,2,3,4,5,6,7,8,9,10) as InputTable  
ON (SELECT * FROM onnx_models WHERE model_id='wines_db_rf_mc_datetime_model') as ModelTable DIMENSION
USING
	Accumulate('')
	ModelOutputFields('output_label')
	ModelInputFieldsMap('total_sulfur_dioxide=total_sulfur_dioxide','alcohol=alcohol','chlorides=chlorides
	','density=density','ph=ph','free_sulfur_dioxide=free_sulfur_dioxide','volatile_acidity=volatile_acidiy')
	OverwriteCachedModel('*')
	) as td order by 1,2,3;