数据块:以数据框为参数(SCALA)的功能

时间:2019-06-27 06:38:47

标签: scala databricks

如何创建以数据框为参数的函数?我遇到以下问题 enter image description here

如何解决?我尝试过“数据框”,但仍然不行

1 个答案:

答案 0 :(得分:0)

@MichaelChau我建议在发表问题之前先做一些研究,如果您能证明您已经尝试解决问题的工作,人们往往会做出更好的回应。话虽这么说(对不起,这有点晚了),下面的代码应该可以回答您的问题:

%scala // sets the command language to scala, I'm testing this in a python notebook ?

import org.apache.spark.sql.DataFrame // this imports the DataFrame type

def writeToSQLWarehouse (df: DataFrame, tableName: String, mode: String) = {
  // I didn't write out all the options, but this should give you a starting place
  df.write
  .option("dbTable", tableName)
  .mode(mode)
  .save()
}

我从databricks documentation page获得了此信息。如有其他疑问,请查看。