【发布时间】:2023-01-24 20:06:27
【问题描述】:
我正在尝试根据 if else 条件将 DataFrame 返回/保存到新的 DataFrame 中。我已经创建了两个数据帧 df1 和 df2 并且应该根据函数中作为参数提供的 id 返回数据帧。我尝试使用 when otherwise 条件语句但它抛出错误。
我的代码:
val final_df = when(institution_id.isin("2341","9706","7801"),df1).otherwise(df2)
**错误:当我在 spark-shell 中执行这段代码时,出现以下错误 - **
Unsupported Literal type class org.apache.spark.sql.Dataset
您能否帮助我提供其他可以帮助解决此问题的替代方案或解决方案?非常感谢。
【问题讨论】:
-
您使用
if (condition) df1 else df2作为其他任何东西。
标签: scala apache-spark