Conditional Schema

Four Stars

Conditional Schema

Hi,

I am absolutely new to Talend and having a hard time figuring out how to parse a file whose layout changes based on a certain identifier.

in the example below schema/layout for RCID through RECORD_KEY does not vary but anything after that can vary based on the value of RCID

string(2) RCID ;  ------ Fixed
string(1) CDGT ; ------ Fixed
string(1) TCND ; ------ Fixed

string(5) RECORD_KEY; ------ Fixed

if (RCID=="01") 

string(4) TRNC;
string(4) FILL1;

if (RCID=="02") 

string(6) PCTY;
string(8) DPCR;

if (RCID == "03")
string(5) ORAC;
string(5) DSTC;

 

Raw data: 

01101234537459762

0350123459876376891

02701234598763768912493

 

Records in the input file may or may not be in the sorted order. In the example above RCID "02" appears before RCID "03". Please note record types 01-through 03 are part of the same record having the same key value "12345". I need to read the file and later aggregate it based on this key. Any ideas? I have searched this forum but did not find anything meaningful.

Does Talend allow Nested Schema definition? For example, if in the same group of records, if I want to say in TMPA that if it record type 01 then do this else if it is record type 02 then do this.

 

 

 

Eight Stars

Re: Conditional Schema

Hello,

In tMap component, there is expression filter and with help of this filter you can define which branch should be used to process the record. Please reed about it here:
https://help.talend.com/reader/QgrwjIQJDI2TJ1pa2caRQA/rvIDyyz_tAaUI42YybAZ6w
As I understand "RCID" depends on the length of the string, so in the expression filter you will evaluate the length of the string as a condition for the branch.
Hope it helps.

Regards
Lojdr

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Talend Cloud Developer Series – Defining Metadata

This video focuses on different methods of adding metadata to a job in Talend Cloud

Watch Now