Arun Vasu
Arun Vasu

Reputation: 367

Get the value from Column

I have a spark API calll like

substr($"fmt_num",(length($"mobile_num")).-(5), 4)

but it will throw an error like

java.lang.ClassCastException: org.apache.spark.sql.Column cannot be cast to java.lang.Integer

How can I get the length of the mobile_num as integer to use as the start index of the substring function?

Upvotes: 1

Views: 783

Answers (1)

Arnon Rotem-Gal-Oz
Arnon Rotem-Gal-Oz

Reputation: 25909

All you need to do is import org.apache.spark.sql.functions._ and you'd get a substring function that works with Column

Upvotes: 1

Related Questions