Hi,
I am trying to create one generic TPT script for data copy purpose and facing some issues with DEFINE SCHEMA syntax. Details are explained below.
Environmental Details:
Teradata PT Version: 14.10.00.02
OS: Linux
Requirement: Create a generic TPT scripts to copy tables data from one server of teradata to another server. Table name, Server details and all other required information will be passed through parameter file dynamically. Thus single TPT script will serve the purpose of multiple tables copy.
Script Created:
DEFINE JOB TABLE_DATA_COPY
(
DEFINE OPERATOR TABLE_DATA_LOAD
TYPE LOAD
SCHEMA *
ATTRIBUTES
(
VARCHAR UserName =@TgtUserName,
VARCHAR UserPassword =@TgtUserPassword,
VARCHAR LogTable =@TgtUtilDatabase||'.'|| @TgtTable||'_log',
VARCHAR TargetTable =@TgtDatabase||'.'|| @TgtTable|| '',
INTEGER BufferSize,
INTEGER ErrorLimit,
INTEGER MaxSessions,
INTEGER MinSessions,
INTEGER TenacityHours,
INTEGER TenacitySleep,
VARCHAR AccountID,
VARCHAR DateForm,
VARCHAR ErrorTable1 =@TgtUtilDatabase||'.'|| @TgtTable||'_ERR1',
VARCHAR ErrorTable2 =@TgtUtilDatabase||'.'|| @TgtTable||'_ERR2',
VARCHAR NotifyExit,
VARCHAR NotifyExitIsDLL,
VARCHAR NotifyLevel,
VARCHAR NotifyMethod,
VARCHAR NotifyString,
VARCHAR PauseAcq,
VARCHAR PrivateLogName,
VARCHAR TdpId =@TgtTptId,
VARCHAR TraceLevel,
VARCHAR WorkingDatabase
);
DEFINE SCHEMA TABLE_SCHEMA FROM TABLE @SrcDatabase||'.'|| @SrcTable
;
DEFINE OPERATOR TABLE_DATA_EXTRACT
TYPE EXPORT
SCHEMA TABLE_SCHEMA
ATTRIBUTES
(
VARCHAR UserName =@SrcUserName,
VARCHAR UserPassword =@SrcUserPassword,
VARCHAR SelectStmt ='SELECT * FROM '|| @SrcDatabase||'.'|| @SrcTable||';',
INTEGER BlockSize,
INTEGER MaxSessions,
INTEGER MinSessions,
INTEGER TenacityHours,
INTEGER TenacitySleep,
INTEGER MaxDecimalDigits =38,
VARCHAR AccountID,
VARCHAR DateForm,
VARCHAR NotifyExit,
VARCHAR NotifyExitIsDLL,
VARCHAR NotifyLevel,
VARCHAR NotifyMethod,
VARCHAR NotifyString,
VARCHAR PrivateLogName,
VARCHAR TdpId =@SrcTptId,
VARCHAR TraceLevel,
VARCHAR WorkingDatabase
);
APPLY
$INSERT
TO OPERATOR
(
TABLE_DATA_LOAD[1]
)
SELECT * FROM OPERATOR
(
TABLE_DATA_EXTRACT[1]
);
);
Parameter File Used for Testing:
TgtTptId= 'TDDEV'
TgtUserName= '******'
TgtUserPassword= '******'
SrcTptId= 'TDTEST'
SrcUserName= '******'
SrcUserPassword= '******'
TgtDatabase= 'EDW_D1_WORK'
TgtTable= 'TABLE1_WORK'
TgtUtilDatabase= 'EDW_D1_UTIL'
SrcDatabase= 'EDW_S1_WORK'
SrcTable= 'TABLE1_WORK'
Run Command: tbuild -f <ScriptName> - v <ParmFileName>
Error Details:
Teradata Parallel Transporter Version 14.10.00.02
TPT_INFRA: TPT02932: Error: Invalid token near line 51 (text was '!')
TPT_INFRA: TPT04017: Exception "Invalid token" caught during job script file parsing/compilation.
Job script compilation failed.
Job terminated with status 8.
Explanation and Furthur Testing: There is no such text (!) in the script. I tried with hardcoding all the parameterized values just to find out the issue but the script failed because of DEFINE SCHEMA statement. When I am replacing the above DEFINE Schema statement with specific column details like below, the script is running fine.
DEFINE SCHEMA TABLE_SCHEMA FROM TABLE
(
CALDR_ID INTEGER,
DT_DSC VARCHAR(50),
DT INTDATE
);
In Teradata Parallel Transporter User Guide, Release 14.10 (B035-2445-082K), it is mentioned that there are features to generate schema definition dynamically. There are several options available to achieve this. I referred (Page number 223 onwards) that user guide and tried several options like below but all of them are failing with same king of error.DEFINE SCHEMA TODAYS_TRANSACTIONS FROM TABLE 'Daily_Trans';
DEFINE SCHEMA PROD_EXT FROM SELECT 'Select a,b,c,sum(d) from Products;';
DEFINE SCHEMA TRANS FROM SELECT OF OPERATOR EXPORT2;
I tried to use all the above options using hardcoded databasename and tablename just to test whether those are working but getting below error - Teradata Parallel Transporter Version 14.10.00.02
TPT_INFRA: TPT04143: Error: Line 39 of Job Script File '/home/*****/Table_Data_Copy1.tpt':
Syntax Error: literal string (DBS table name) expected.
Job script preprocessing failed.
Job terminated with status 8.
It seems that those syntax are not working. Then I tried with obsolete sysnax DEFINE SCHEMA <SchemaName> <TableName>;
But that syntax is also giving same kind of error. Is this a bug of teradata? How can I fix this issue and create my generic script?