Publishing NUMBER or DECIMAL Types to an Avro Value

Teradata Vantageā„¢ DATASET Data Type

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1198-162K

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"]}]}}