Skip to main content

Datometry Documentation

Map Teradata NUMERIC to BigQuery INT64 Data Type

The numeric_to_int_emulation hint maps the Teradata NUMERIC data type to the BigQuery INT64 data type.

The BigQuery NUMERIC data type uses a fixed decimal precision and scale, in which the precision is 38 and the scale is 9. Precision is the number of digits that the number contains. Scale is how many of these digits appear after the decimal point. Because the BigQuery NUMERIC data type is more constrained than Teradata's NUMERIC data type, it cannot represent all of the values available to Teradata. For this reason, you can specify if Hyper-Q should map the Teradata NUMERIC data type to the BigQuery INT64 data type.

To learn more about BigQuery numeric data types, see Data types in the Google bigQuery documentation.

Hyper-Q applies the following mapping to emulating Teradata NUMERIC and DECIMAL data types for use with BigQuery.

Condition

BigQuery Data Type

Description

precision <= 18 and scale == 0

INT64

Configurable using the numeric_to_int_emulation hint.

precision <= 29 and scale <= 9

NUMERIC

Default mapping rule in Hyper-Q.

All others

BIGNUMERIC

Default mapping rule in Hyper-Q.

Using the above mapping rules, a Teradata NUMERIC data type with a precision of 30 and a scale of 6 maps to a NUMERIC data type on BigQuery.

In the following example, the Teradata SQL statement includes a column (column1) that, on Teradata, uses the NUMERIC datatype. Hyper-Q maps this to a column with a data type of INT64.

CREATE TABLE table_name (column1 dec(18,0), column2 dec(19,0), column3 dec(18,1));

The resulting CREATE TABLE statement on BigQuery after Hyper-Q emulation. Note that BigQuery creates column1 with a data type of INT64.

CREATETABLE
    database.table_name (
        'column1' INT64 ,
        'column2' NUMERIC ,
        'column3' NUMERIC 
   ) );

Warning

The Data Definition Language (DDL) commands in SQL are used to create the database schema and to define the type and structure of the data that will be stored in the database. For this reason, once you execute DDL commands on your system, you can not enable and then disable numeric_to_int_emulation. You must use the same setting at all times once you have created your database.

The syntax for numeric_to_int_emulation is:

numeric_to_int_emulation = true | false

where:

Parameter

Description

true

Enables Teradata NUMERIC to BigQuery INT64 data type mapping for precision <= 18 and scale == 0.

false

Maps Teradata NUMERIC to BigQuery BIGNUMERIC. This is the default setting.

Example 15. Specify that Hyper-Q Map Teradata NUMERIC to BigQuery INT64 as a Global Setting

You can specify numeric_to_int_emulation as a global setting in the Hyper-Q configuration file (dtm.ini). To enable numeric_to_int_emulation, set it to true. The default value is false.

"gateway".numeric_to_int_emulation = true

To learn more about specifying a hint as a gateway option in the Hyper-Q configuration file, see Gateway Configuration Parameters.Gateway Configuration Parameters