Issue in Expression Editor

Six Stars

Issue in Expression Editor

Hello Community,

 

I have used the below logic to convert String datatype to Float inside Expression Builder of tMap - 

(row36.Spillover_km3 == null || row36.Spillover_km3.isEmpty() == true)?0  :Float.valueOf(row36.Spillover_km3) 

but I'm getting the below error - 

Exception in component tMap_13 
java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1842)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at java.lang.Float.valueOf(Float.java:416)

 

Can anyone please let me know how to rectify this issue?

 

For reference I have attached the job screenshot.

 

Thanks in advance!

 

Best Regards.


Accepted Solutions
Sixteen Stars TRF
Sixteen Stars

Re: Issue in Expression Editor

@dipanjan93, does this help?

If so, thanks to mark your case as solved (Kudos also accepted as a bonus)


TRF

View solution in original post


All Replies
Forteen Stars

Re: Issue in Expression Editor

@dipanjan93,

can you try the below one.

 

(row36.Spillover_km3 == null || ("").equals(row36.Spillover_km3))?0  :Float.valueOf(row36.Spillover_km3) 

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Six Stars

Re: Issue in Expression Editor

Hi @manodwhb

 

I have tried your approach but the issue still persists. 

Sixteen Stars TRF
Sixteen Stars

Re: Issue in Expression Editor

What about this one:

(row36.Spillover_km3 == null || 
("").equals(row36.Spillover_km3.replaceAll(" ", ""))) ? 0.0f : Float.valueOf(row36.Spillover_km3)

TRF
Forteen Stars

Re: Issue in Expression Editor

@dipanjan93,since you might have space issue use the below way.i have tested below one working as expected.

 

 

(row1.Col == null || ("").equals(StringHandling.TRIM(row1.Col)))?0  :Float.valueOf(row1.Col) 

 

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Six Stars

Re: Issue in Expression Editor

Hi @TRF

 

Nope still the issue persists. Although now something new has come up -

 

java.lang.NumberFormatException: For input string: "null"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at java.lang.Float.valueOf(Float.java:416)

Highlighted
Sixteen Stars TRF
Sixteen Stars

Re: Issue in Expression Editor

The field contains the string "null" (4 characters). Write line this:
(row36.Spillover_km3 == null || ("null").equalsIgnoreCase(row36.Spillover_km3 ||
("").equals(row36.Spillover_km3.replaceAll(" ", ""))) ? 0.0f : Float.valueOf(row36.Spillover_km3)

TRF
Sixteen Stars TRF
Sixteen Stars

Re: Issue in Expression Editor

@dipanjan93, does this help?

If so, thanks to mark your case as solved (Kudos also accepted as a bonus)


TRF

View solution in original post

Six Stars

Re: Issue in Expression Editor

Many Thanks @TRF and @manodwhb for your prompt response! It solved the issue.

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

Put Massive Amounts of Data to Work

Learn how to make your data more available, reduce costs and cut your build time

Watch Now

How OTTO Utilizes Big Data to Deliver Personalized Experiences

Read about OTTO's experiences with Big Data and Personalized Experiences

Blog

Talend Integration with Databricks

Take a look at this video about Talend Integration with Databricks

Watch Now