Publishing NUMBER or DECIMAL Types to an Avro Value - Analytics Database - Teradata Vantage

DATASET Data Type

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2023-10-30
dita:mapPath
bka1628112240653.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
ekk1458586304878
lifecycle
latest
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"]}]}}