小编jos*_*era的帖子

合并火花数据框中的列

我做了一个算法,我得到了许多名称逻辑数字后缀的列,我需要做coalesce但我不知道如何应用coalesce不同数量的列.

例:

|id|logic_01|logic_02|logic_03|
|1 |  null  |a       |null    |  
|2 |  null  |b       |null    |   
|3 |   c    | null   |null    |   
|4 |  null  | null   |d       |
Run Code Online (Sandbox Code Playgroud)

响应:

|id|logic|
|1 |  a  |  
|2 |  b  |   
|3 |  c  |   
|4 |  d  | 
Run Code Online (Sandbox Code Playgroud)

另一个例子:

|id|logic_01|logic_02|logic_03|logic_04|
|1 |  null  |a       |null    |null    |  
|2 |  null  | null   |null    |b       |   
|3 |   c    | null   |null    |null    | …
Run Code Online (Sandbox Code Playgroud)

null scala user-defined-functions apache-spark apache-spark-sql

4
推荐指数
1
解决办法
9303
查看次数

优点使用BiFunction Java 8

我理解为BiFunction的合同,其函数方法为apply(T t,U u),它接受两个参数.但事实是,我不明白使用它的优点.你能帮帮我吗?

java functional-programming

1
推荐指数
1
解决办法
8936
查看次数