Four Stars

Bug in tSampleRow Range when using context variables

I am writing data into a DB2 database. Sadly this is slow because the ODBC driver.

For test purposes, I am sampling the data when the context "test" is used, else I take all of them.

 

To show the issue, I created a minimal working example:

mwe-tsamplerow.png

It works flawlessly, when the "Range" field in "tSampleRow_1" component is set to: "1,5,10..20" (the pre-filled example).

What I tried and is not working is the following: "1.." + context.db2_table_HCWH2H1P_sampleSize

In the "test" context, the context variable is set to 100, and in "production" to 99999999.

 

The job is not compiling. The source shows:

String[] rangetSampleRow_1 = "1.." + context.db2_table_HCWH2H1P_sampleSize.split(",");

with the error:

Type mismatch: Cannot convert from String to String[]

My guess is, that "Talend Open Studio for Big Data" is taking the value in the "Range" field, and puts a '.split(",")' at the end.

What happens is, that the context variable gets split rather than the whole string. It ends up with a "String" and this mismatches the "String[]" variable type of "rangetSampleRow_1".

 

An easy solution is, to put some brackets around the "Range" field, and append the '.split(",")' after the closing bracket.

 

For my case, I worked around the problem by putting the whole string "1..100" into the context variable, rather than only the upper bound "100".

 

Additional information:

- Product: Talend Open Studio for Big Data

- Version: 6.4.1

- OS: Win10

- Java: JDK 1.8

 

1 ACCEPTED SOLUTION

Accepted Solutions
Twelve Stars TRF
Twelve Stars

Re: Bug in tSampleRow Range when using context variables

Hi,

Use this syntax:

("1.." + context.db2_table_HCWH2H1P_sampleSize)

Hope this helps.


TRF
3 REPLIES
Twelve Stars TRF
Twelve Stars

Re: Bug in tSampleRow Range when using context variables

Hi,

Use this syntax:

("1.." + context.db2_table_HCWH2H1P_sampleSize)

Hope this helps.


TRF
Four Stars

Re: Bug in tSampleRow Range when using context variables

This works fine. But I still think that it is a bug in Talend.

 

Twelve Stars TRF
Twelve Stars

Re: Bug in tSampleRow Range when using context variables

Not really. This is due to the way TOS concatenates its part when generationg the Java code.
However don't forget to mark the solution as accepted.

TRF