Talend execution pre conditon set

Five Stars

Talend execution pre conditon set

Hello Everyone,

i have a talend job which use tHiveRow to run query , how can i add some validation before run query.

So for example ,

Query Test1= insert into table a select * from table B.

Validation Test2=select max(date) from B.

if the result of Test2='2019-09-05' , then exit running but not throw excepting or error log, if Test2='2019-10-05' , then run query.

 

i am very novice in talend , please help and thanks so much in advance.

Tags (1)

Accepted Solutions
Community Manager

Re: Talend execution pre conditon set

Hi
Use a tHiveInput to query the max date and use runIf trigger to control the tHiveRow execution, eg:
tHiveInput--main--tJavaRow--runIf--tHiveRow

on tJavaRow:
if(TalendDate.compareDate(input_row.dateColumnName, TalendDate.parseDate("yyyy-MM-dd", "2019-10-05"))==0){
context.isContinue=true;
}else{
context.isContinue=false;
}

//Define a context variable isContinue with boolean type.

Set the condition of runIf as:
context.isContinue

Regards
Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post


All Replies
Community Manager

Re: Talend execution pre conditon set

Hi
Use a tHiveInput to query the max date and use runIf trigger to control the tHiveRow execution, eg:
tHiveInput--main--tJavaRow--runIf--tHiveRow

on tJavaRow:
if(TalendDate.compareDate(input_row.dateColumnName, TalendDate.parseDate("yyyy-MM-dd", "2019-10-05"))==0){
context.isContinue=true;
}else{
context.isContinue=false;
}

//Define a context variable isContinue with boolean type.

Set the condition of runIf as:
context.isContinue

Regards
Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post

Highlighted
Five Stars

Re: Talend execution pre conditon set

Thanks so much Shong. Just a note for other new learner , when we are using the TalendDate.compareDate(input_row.dateColumnName, TalendDate.parseDate("yyyy-MM-dd", "2019-10-05") , have to make sure both columns are date type.

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

Introduction to Talend Open Studio for Data Quality

Find out about Talend Open Studio for Data Quality

Watch Now

Enabling Data Governance

Learn how to enable Data Governance

Watch Now

The Definitive Guide to Government Data Quality

Take a peek at the definitive guide to Government Data Quality

Read