我使用pyspark使用sparksql(spark1.6.1),我需要从一个配置单元元存储加载一个表,并将Dataframe的结果写入另一个配置单元元存储。
我想知道如何才能将两个不同的元存储用于一个sparksql脚本?
这是我的剧本。
# Hive metastore 1
sc1 = SparkContext()
hiveContext1 = HiveContext(sc1)
hiveContext1.setConf("hive.metastore.warehouse.dir", "tmp/Metastore1")
# Hive metastore 2
sc2 = SparkContext()
hiveContext2 = HiveContext(sc2)
hiveContext2.setConf("hive.metastore.warehouse.dir", "tmp/Metastore2")
# Reading from a table presnt in metastore1
df_extract = hiveContext1.sql("select * from emp where emp_id =1")
# Need to write the result into a different dataframe
df_extract.saveAsTable('targetdbname.target_table',mode='append',path='maprfs:///abc/datapath...')
2条答案
按热度按时间t3irkdon1#
热释光;dr不可能使用一个配置单元元存储(对于某些表)和另一个(对于其他表)。
因为sparksql支持单个配置单元元存储(在sharedstate中),而不考虑
SparkSessions
从不同的Hive元存储读取和写入在技术上是不可能的。8hhllhi22#
hotelsdotcom专门为此开发了一个应用程序(waggledance)https://github.com/hotelsdotcom/waggle-dance. 使用它作为代理,你应该能够实现你的目标