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

DATASET Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
des1556232910526.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1198
lifecycle
previous
Product Category
Teradata Vantageā„¢

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":
{"string":"12345678901234567890123456789.012345679"},"c":
{"string":"12345678901234567890123456789.012345679"}}]
data.GETSCHEMA() {"type":"array","items":{"type":"record","name":"rec_0","fields":
[{"name":"a","type":["null","int"]},{"name":"b","type":["null","string"]},
{"name":"c","type":["null","string"]}]}}