Default value for strings are not being used within tMap

One Star

Default value for strings are not being used within tMap

I'm attempting to map a Excel spread sheet using tFileInputExcel to output a CSV using tFileOutputDelimiter. As you'll notice in the screenshots below I've currently only mapped the primary keys to each other. I've also specified default values on the output side for column which will NOT have rows mapped to them. The default values for columns with the type of integers work as expected (the default value gets output into the CSV file). However, the default values for the columns with the type of String do not work and as a work around I've created variables with the various default values and have mapped them to the corresponding columns. I've double checked and my default values are surrounded with double quotes but for some reason are not being output to the CSV.
Job Designer:
https://www.evernote.com/shard/s1/sh/4155453a-9fa8-41c0-95d7-da5e7f5a5376/2c20f222d2887a152c02342efa...
tMap
https://www.evernote.com/shard/s1/sh/7160f793-c36d-4959-a7bc-def911dd221f/daa74fc27a7e4bd5391ffab493...
Cheers,
AJ
One Star

Re: Default value for strings are not being used within tMap

Hello,
I prefere to use default value in tMap on output expression.
I think this default value is use to write on DB table with the DB table definition.
For number 0 is default for java type , test with an other numeric value as default
Regards
Seventeen Stars

Re: Default value for strings are not being used within tMap

The default values will never be used to fill unfilled values. It is a common and easy to explain mistake.
It would be great if Talend could implement this behavior but it is not implemented yet.
To set the 0 as default value for the primitive type integer does not make sense because Java already filled the variable with 0.
The only usage of default values so far is for the creation of tables. Here the default value will be used for a couple of databases.
If you want to use default Strings: implement it in the database (but in most cases you have to avoid using this column in your SQL statement because null is also a value and e.g. MySQL does not use the default value if you fill a column explicit with null.
You could implement it with small pieces of Java code:
row1.store != null ? row1.store : "admin"

Yes I know, looks silly but as long Talend does not implement it we have to do this.
One Star

Re: Default value for strings are not being used within tMap

You could implement it with small pieces of Java code:
row1.store != null ? row1.store : "admin"


The problem with using this is I never map an input column to the output column so I can not test for null because it'll always be null but I suppose I can just put the default value in the expression column.
Seventeen Stars

Re: Default value for strings are not being used within tMap

Yes, you can use my suggestion in any expression editor.