Hi, This UDF on substring works
scala> val SubstrUDF = udf { (s: String, start: Int, end: Int) => s.substring(start, end) } SubstrUDF: org.apache.spark.sql.expressions.UserDefinedFunction = UserDefinedFunction(<function3>,StringType,Some(List(StringType, IntegerType, IntegerType))) I want something similar to this scala> sql("""select lpad("str", 10, "0")""").show +----------------+ |lpad(str, 10, 0)| +----------------+ | 0000000str| +----------------+ scala> val SubstrUDF = udf { (s: String, len: Int, chars: String) => lpad(s, len, chars) } <console>:40: error: type mismatch; found : String required: org.apache.spark.sql.Column val SubstrUDF = udf { (s: String, len: Int, chars: String) => lpad(s, len, chars) } Any ideas? Thanks Dr Mich Talebzadeh LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw <https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>* http://talebzadehmich.wordpress.com *Disclaimer:* Use it at your own risk. Any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on this email's technical content is explicitly disclaimed. The author will in no case be liable for any monetary damages arising from such loss, damage or destruction.