Skip to main content

Sorting entries based on dynamic schema

This scenario applies to all Talend products.

For more technologies supported by Talend, see Talend components.

In this scenario we will sort entries in an input file based on a dynamic schema, display the sorting result on the Run console, and save the sorting result in an output file. For more information about the dynamic schema feature, see Talend Studio User Guide.

  • Drop the components required for this use case: tFileInputDelimited, tSortRow, tLogRow and tFileOutputDelimited from the Palette to the design workspace.

  • Connect these components together using Row > Main links.

  • Double-click the tFileInputDelimited component to display its Basic settings view.

Information noteWarning:

The dynamic schema feature is only supported in Built-In mode and requires the input file to have a header row.

  • Select Built-In from the Property Type list.

  • Click the [...] button next to the File Name field to browse to your input file. In this use case, the input file cars.csv has five columns: ID_Owner, Registration, Make, Color, and ID_Reseller.

  • Specify the header row in Header field. In this use case the first row is the header row.

  • Select Built-In from the Schema list, and click Edit schema to set the input schema.

Information noteWarning:

The dynamic column must be defined in the last row of the schema.

  • In the schema editor, add two columns and name them ID_Owner and Other respectively. Set the data type of the Other column to Dynamic to retrieve all the columns undefined in the schema.

  • Click OK to propagate the schema and close the schema editor.

  • Double-click tSortRow to display the Basic settings view.

  • Add a row in the Criteria table by clicking the plus button, select Other under Schema column, select alpha as the sorting type, and select the ascending or descending order for data output.

Information noteWarning:

Dynamic column sorting works only when the sorting type is set to alpha.

  • To view the output in the form of a table on the Run console, double-click the tLogRow component and select the Table option in the Basic settings view.

  • Double-click the tFileOutputDelimited component to display its Basic Settings view.

  • Click the [...] button next to the File Name field to browse to the directory where you want to save the output file, and then enter a name for the file.

  • Select the Include Header check box to retrieve the column names as well as the sorted data.

  • Save your Job and press F6 to run it.

    The sorting result is displayed on the Run console and written into the output file.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!