从 Teradata 导出字节/图形数据的最佳方法是什么?对于数据迁移项目,有人可以指导我如何将数据从 teradata 导出到雪花。我正在使用 TPT 脚本和 tdload 方法,但是,它似乎不起作用。
我遵循的方法:
使用 Teradata 中的 FROM_BYTES() 方法将数据从字节转换为 ASCII。但是,在摄取过程中,我无法将其恢复到原始状态。
使用带有 base10/base16 的 FROM_BYTES() 方法进入所需的格式,但是,我在该过程中面临同样的问题。
下面是表结构:
CREATE SET TABLE DBC.AccessRights ,FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO,
MAP = TD_DATADICTIONARYMAP
(
UserId BYTE(4) NOT NULL,
DatabaseId BYTE(4) NOT NULL,
TVMId BYTE(6) NOT NULL,
FieldId SMALLINT FORMAT '---,--9' NOT NULL,
AccessRight CHAR(2) CHARACTER SET LATIN UPPERCASE NOT CASESPECIFIC NOT NULL,
WithGrant CHAR(1) CHARACTER SET LATIN UPPERCASE NOT CASESPECIFIC NOT NULL,
GrantorID BYTE(4) NOT NULL,
AllnessFlag CHAR(1) CHARACTER SET LATIN UPPERCASE NOT CASESPECIFIC NOT NULL,
CreateUID BYTE(4),
CreateTimeStamp TIMESTAMP(0),
LastAccessTimeStamp TIMESTAMP(0),
AccessCount INTEGER FORMAT '--,---,---,--9')
PRIMARY INDEX ( UserId )
PARTITION BY ( RANGE_N((ID2BIGINT(DatabaseId )) MOD 1073741824 BETWEEN 0 AND 1073741823 EACH 1 ),
RANGE_N(ID2BIGINT(TVMId ) BETWEEN 0 AND 4294967295. EACH 1 )ADD 2 );
Tpt脚本:
USING CHARACTER SET UTF8
DEFINE JOB EXPORT_DELIMITED_FILE
DESCRIPTION 'Export rows from a Teradata table to a unformatted file' ( DEFINE SCHEMA FILE_SCHEMA (
UserId BYTE(4),
DatabaseId BYTE(4),
TVMId BYTE(6),
FieldId SMALLINT,
AccessRight CHAR(4),
WithGrant CHAR(2),
GrantorID BYTE(4),
AllnessFlag CHAR(2),
CreateUID BYTE(4),
CreateTimeStamp TIMESTAMP(0),
LastAccessTimeStamp TIMESTAMP(0),
AccessCount INTEGER
);
DEFINE OPERATOR SQL_SELECTOR
TYPE SELECTOR SCHEMA FILE_SCHEMA ATTRIBUTES
(
VARCHAR PrivateLogName = 'selector_log',
VARCHAR TdpId = <host_id>,
VARCHAR UserName = <user_name>,
VARCHAR UserPassword = <password>,,
VARCHAR SelectStmt = 'SELECT * FROM DBC.AccessRights;',
VARCHAR LobDirectoryPath = <lob_dir>
);
DEFINE OPERATOR FILE_WRITER TYPE DATACONNECTOR CONSUMER SCHEMA * ATTRIBUTES
(
VARCHAR PrivateLogName = 'dataconnector_log',
VARCHAR DirectoryPath = <dir_path>,
VARCHAR FileName = 'file.csv',
VARCHAR FORMAT= 'BINARY',
VARCHAR OpenMode = 'Write'
);
APPLY TO OPERATOR (FILE_WRITER)
SELECT * FROM OPERATOR (SQL_SELECTOR);
);