Scala Functional Programming Metrics calculation


Hello Sir,

I’m trying to change an existing SQL “CASE WHEN … ELSE …” calculated column to implement in functional programming Scala 2.11.8 APIs…How do we implement this?

scenario 1:


when column1= o AND column2 = "XYX"

Then value

else 0 END

scenario 2:


when COALESCE(SUM(column1),0)= o AND COALESCE(SUM(column2),0) <> 0

THEN value

when COALESCE(SUM(column1),0) = 0 AND COALESCE(SUM(column2),0) = 0 THEN 0

*ELSE COALESCE(CAST(((SUM(column)/SUM(column))100) AS DECIMA(10,5),0)

END metrics

I have more number of CASE … WHEN statements.What is the equivalent of COALESCE in scala to check “not a number value” or null value for aggregating the column.
Is there any ABS() function available in scala?

How do we achieve these kind of metrics calculation using scala?.Please suggest me a idea on this proceed.


The question is a bit apples-and-oranges – you can’t directly compare a specialized language like SQL to a general-purpose one like Scala.

Can you provide more context? The question might make more sense in the context of a particular SQL library or a specific data structure, but the way you’ve asked it, it isn’t quite answerable – the answer depends on the details of what you’re working in…