Introduction. Teradata QueryGrid
Pubblicità
Pubblicità
CHAPTER 3
Stored Procedures for Teradata QueryGrid:
Teradata Database-to-Hadoop
Introduction
Teradata supplies stored procedures that you can use to create and drop Hadoop tables. You can use these procedures so that SQL scripts can export data in a standalone manner.
HCTAS Stored Procedure
Purpose
To create the schema of a local Teradata table in Hadoop.
You can use this procedure so that SQL scripts can export data in a standalone manner.
You must have SELECT privilege on the foreign server to use this stored procedure.
Syntax
HCTAS ( 'table_name', 'partition_columns_list ', 'table_definition', 'foreign_servername', 'hive_db_name' )
SYSLIB.
Syntax Elements
table_name
The name of the Teradata table to use for referencing column type definitions when creating an Apache Hive table. Column types are translated to the corresponding column types supported by the INSERT.
partition_columns_list
A comma-separated, ordered list of Teradata columns to use as partitioned columns in
Hive.
table_definition
The Hive table definition information, such as location or format type.
foreign_servername
The name of the foreign server that you want to create the table on. Used for permissions and connection information.
Teradata QueryGrid: Teradata Database-to-Hadoop User Guide 49
Chapter 3 Stored Procedures for Teradata QueryGrid: Teradata Database-to-Hadoop
HCTAS Stored Procedure
hive_db_name
The name of the Hive database in which you want to create the table.
Supported Data Types
HCTAS currently supports the following mapping of data types.
Teradata Data Type
INT
BIGINT
BYTEINT
BYTE
NUMBER
REAL
SMALLINT
VARBYTE
VARCHAR
CHAR(n)
DECIMAL(n)
DATE
TIMESTAMP
ALL ELSE
2.1 Hive Data Type
INT
BIGINT
TINYINT
BINARY
DOUBLE
DOUBLE
SMALLINT
BINARY
STRING
CHAR(n)
DECIMAL(n)
DATE
TIMESTAMP
STRING
1.3.2 Hive Data Type
INT
BIGINT
TINYINT
BINARY
DOUBLE
DOUBLE
SMALLINT
BINARY
STRING
STRING
DECIMAL
STRING
STRING
STRING
Usage Notes
To use HCTAS, you must have the following name value pairs defined for the foreign server:
• Hive port: Use port 10000 for the hive server, for example, hiveport(‘10000’).
• Server name: The hostname or IP address of the Hive server, for example, server(‘hive_metastore_server’).
Examples of Using HCTAS to Create a Table Schema
This basic query creates a table without a partition on the Hadoop server.
CALL SYSLIB.HCTAS('test',null,null,'hive_metastore_server','default') ;
This syntax results in the following output: hive> describe test;
OK
50 Teradata QueryGrid: Teradata Database-to-Hadoop User Guide
Scarica
Pubblicità