合并两个配置单元表(不同的列大小)-pyspark

问题描述 投票:0回答:1

我有一个带有配置文件的配置单元表姓名,联系方式,地址,主题

Name  Contact   Address  Subject
abc   1111      Mumbai    maths
egf   2222      nashik    science
pqr   3333      delhi     history

And other table with schema **Name ,Contact** 
Name   Contact
xyz    4444  
mno    2222 

预期输出

Name  Contact   Address  Subject
abc   1111      Mumbai    maths
pqr   3333      delhi     history
xyz   4444      null      null
mno   2222      nashik    science

我尝试了加入操作,但无法获得正确的输出

pyspark hive hiveql pyspark-sql
1个回答
0
投票

尝试以下操作:

select name, contact, address, subject
  from table1
 union all
select name, contact, NULL as address, NULL as subject
  from table2
© www.soinside.com 2019 - 2024. All rights reserved.