复制基于在 spark sql 中具有 2 个值的列的行
Duplicate a row based in a column that has 2 values in spark sql
我有一个看起来像这样的临时视图。
ID Activity
1 Yes
2 Yes
3 No
4 Yes
我想要的是通过将 'All' 值添加到 Activity
来复制一行
预期结果为:
ID Activity
1 Yes
2 Yes
3 No
4 Yes
1 All
2 All
3 All
4 All
我尝试通过 Zeppelin 创建它,但我无法更新视图。
请问有什么办法吗?
可惜只能用SQL
在此先感谢您的帮助
您可以使用union
select Id, Activity
from view
union all
select Id, 'All'
from view
我有一个看起来像这样的临时视图。
ID Activity
1 Yes
2 Yes
3 No
4 Yes
我想要的是通过将 'All' 值添加到 Activity
来复制一行预期结果为:
ID Activity
1 Yes
2 Yes
3 No
4 Yes
1 All
2 All
3 All
4 All
我尝试通过 Zeppelin 创建它,但我无法更新视图。
请问有什么办法吗?
可惜只能用SQL
在此先感谢您的帮助
您可以使用union
select Id, Activity
from view
union all
select Id, 'All'
from view