【发布时间】:2019-08-13 14:09:45
【问题描述】:
我正在学习 scala 的火花。我正在尝试使用某种 case 语句将一些值发布到列中。任何帮助,将不胜感激。
在输入 DF 中,我有列客户、订单、类型、消息、消息 1、消息 2。 message1 & message2 在输入 DF 中将始终为空。我想在类型为“V”时在消息 1 中发布消息,并在类型为“A”时在消息 2 中发布消息。在输出 DF 中,我应该只有一条客户记录。
DF1:
cust, order, type, message, message1, message2
c1, o1, V, Verified, null, null
c1, o1, A, Approved, null, null
c2, o2, A, Approved, null, null
c3, o3, V, Verified, null, null
outputDF:
cust, order, type, message, message1, message2
c1, o1, A, Approved, Verified, Approved
c2, o2, A, Approved, null, Approved
c3, o3, V, Verified, Verified, null
【问题讨论】:
-
您可以使用
when/otherwise(参见链接中的示例)。
标签: scala apache-spark apache-spark-sql