在spark(scala/sql)中,如何调用sql文件并使用withcolumn函数执行文件中提到的case语句

uqdfh47h  于 2021-05-16  发布在  Spark
关注(0)|答案(0)|浏览(266)

假设下面的case语句是在sql/txt文件中(下面的case语句只是示例,但实际用例有一个复杂的case语句,不能用在direct.withcolumn函数中)

  1. case
  2. when col1 = "INR" Then income"
  3. when col 2= "eur" then "out"
  4. else "passthroug"
  5. end as trantype

我需要在下面的代码中调用上面的case语句sql,有没有自定义函数或者不同的调用方法

  1. val tab = sparksession.table(db.table).withColumn("new colum", <need to call sql case statement file here>) Is there any option to call the sql file?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题