如何为saveastable使用不同的配置单元元存储?

envsm3lx  于 2021-06-26  发布在  Hive
关注(0)|答案(2)|浏览(369)

我使用pyspark使用sparksql(spark1.6.1),我需要从一个配置单元元存储加载一个表,并将Dataframe的结果写入另一个配置单元元存储。
我想知道如何才能将两个不同的元存储用于一个sparksql脚本?
这是我的剧本。

  1. # Hive metastore 1
  2. sc1 = SparkContext()
  3. hiveContext1 = HiveContext(sc1)
  4. hiveContext1.setConf("hive.metastore.warehouse.dir", "tmp/Metastore1")
  5. # Hive metastore 2
  6. sc2 = SparkContext()
  7. hiveContext2 = HiveContext(sc2)
  8. hiveContext2.setConf("hive.metastore.warehouse.dir", "tmp/Metastore2")
  9. # Reading from a table presnt in metastore1
  10. df_extract = hiveContext1.sql("select * from emp where emp_id =1")
  11. # Need to write the result into a different dataframe
  12. df_extract.saveAsTable('targetdbname.target_table',mode='append',path='maprfs:///abc/datapath...')
t3irkdon

t3irkdon1#

热释光;dr不可能使用一个配置单元元存储(对于某些表)和另一个(对于其他表)。
因为sparksql支持单个配置单元元存储(在sharedstate中),而不考虑 SparkSessions 从不同的Hive元存储读取和写入在技术上是不可能的。

8hhllhi2

8hhllhi22#

hotelsdotcom专门为此开发了一个应用程序(waggledance)https://github.com/hotelsdotcom/waggle-dance. 使用它作为代理,你应该能够实现你的目标

相关问题