Setting precision for BigDecimal numbers through schema - Cloud - 7.3

Talend Studio User Guide

Version
Cloud
7.3
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Cloud
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development

About this task

You can have numbers that are of BigDecimal type being displayed at a given precision (that is, the number of digits to the right of the decimal point) by setting the precision for the corresponding columns in the schema. With the precision set for a schema column that is of BigDecimal type, numbers in the column will be rounded in the HALF_UP mode.

The following Job displays the same number at different precisions. Take the following steps to set up and run the Job.

Procedure

  1. Launch Talend Studio and create an empty standard Job.
  2. Drag and drop tFixedFlowInput and tLogrow to the work space from Palette.
  3. Connect the two components using a Row > Main connection.
  4. Double-click the tFixedFlowInput component to open its Basic settings view and do the following.
    1. Open the schema editor by clicking the [...] button next to Edit schema and add four columns, which are of the BigDecimal type and have different precision settings.
    2. Select the Use Single Table option and enter the same value (new BigDecimal("123456.9876") in this example) for the four columns.
    3. Leave the other options as they are.
  5. Double-click the tLogRow component to open its Basic settings view and do the following.
    1. Click the Sync columns button to synchronise the schema of the component with that of the tFixedFlowInput component.
    2. Select Table (print values in cells of a table) option.
    3. Leave the other options as they are.
  6. Press F6 to run the Job.

    The following execution result shows that the numbers are rounded according to the precision settings in the schema.