Talend conditional expression trying to return a value from dimension table with if then else

时间:2016-10-20 18:58:01

标签: java talend

I'm new to Java due to a recent Talend adoption. I need help with the conditional statement below: it gives me an error that reads :

row3 cannot be resolved to a variable

All of the data types are strings.

row1.Vendor_Name.equals(row3.CP_VENDOR_NAME)?row3.VENDOR:row1.Vendor_Name

Syntactically my goal is : if row1.Vendor_Name has the same characters as row3.CP_VENDOR_NAME then return row3.VENDOR else return row1.VENDOR_NAME

Do I need to allow for NULL (read blank) fields? Any help and clarification would be much appreciated.

2 个答案:

答案 0 :(得分:0)

这取决于您的工作布局。如果您需要更具体的帮助,您需要提供工作的架构或屏幕截图。

具体来说,这意味着row3未初始化。不知道你的工作,这可能意味着:

  • 此作业中不存在row3
  • row3未连接到您的组件
  • row3将在稍后使用,但尚未使用

除此之外,您的陈述看起来很符合您的要求。

此外,请不要忘记您没有检查NULL。当语句有效时,您可能需要更改它:

(row1.Vendor_Name != NULL && row1.Vendor_Name.equals(row3.CP_VENDOR_NAME)) ? 
 row3.VENDOR : row1.Vendor_Name

答案 1 :(得分:0)

我发现我在错误的地方表达了正确的表达方式。我不得不将它从inputtable.column移动到感兴趣的outputtable.column。

此外,在需要更多过滤操作后,我发现我可以在底部的输入表中添加一个表达式作为" global"通过单击输入表顶部的白色箭头进行筛选,从而释放outputtable.column表达式位置以与另一个表达式一起使用。

希望这有助于其他人。感谢所有快速回复。