17.10 - Publishing NUMBER or DECIMAL Types to an Avro Value - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - DATASET Data Type

Advanced SQL Engine
Teradata Database
Release Number
Release Date
July 2021
Content Type
Programming Reference
Publication ID
English (United States)

When publishing NUMBER or DECIMAL types from a table to an Avro value, the schema is written out as a string instead of a double type. Because NUMBER and DECIMAL use a higher precision, using a double or other relevant primitive type can result in a loss of precision. Using a string prevents this loss of information.

The schema looks like the following when using NUMBER or DECIMAL types:
CREATE TABLE avrotest(a INTEGER, b DECIMAL(38,9), c NUMBER(38,9));
INSERT INTO avrotest(1, 12345678901234567890123456789.012345679, 12345678901234567890123456789.012345679);
SELECT data.tojson(), data.getschema() FROM DATASET_PUBLISH
    ON (SELECT * FROM avrotest)
) as L;
*** Query completed. One row found. 2 columns returned.
 *** Total elapsed time was 1 second.

   data.TOJSON() [{"a":{"int":1},"b":
data.GETSCHEMA() {"type":"array","items":{"type":"record","name":"rec_0","fields":