【问题标题】:sparklyr can't see databases created in Hive and vice versasparklyr 看不到在 Hive 中创建的数据库,反之亦然
【发布时间】:2017-10-31 23:16:10
【问题描述】:

我在本地安装了 Apache Hive,并尝试通过 Rstudio/sparklyr 读取表。

我使用 Hive 创建了一个数据库:

hive> CREATE DATABASE test;

我正在尝试使用以下 R 脚本读取该数据库:

library(sparklyr)
library(dplyr)
library(DBI)

spark_disconnect_all()

Sys.setenv(SPARK_HOME = "/home/alessandro/spark-2.1.0-bin-hadoop2.7")

config <- spark_config()
config$spark.executor.instances <- 4
config$spark.executor.cores <- 4
config$spark.executor.memory <- "4G"
config$spark.sql.hive.metastore <- "/home/alessandro/spark-warehouse"
config$hive.metastore.warehouse.dir <- "/home/alessandro/spark-warehouse"
sc <- spark_connect(master="local", config=config, version="2.1.0")

dbGetQuery(sc, "show databases")

不过,dbGetQuery(sc, "show databases") 没有显示创建的数据库,这很尴尬,因为数据库文件夹 test.db 正确放置在指定的 hive.metastore.warehouse.dir 中。

同样,如果我使用 dbGetQuery(sc, "CREATE DATABASE test2") 创建数据库,则会在 hive.metastore.warehouse.dir 中创建一个数据库文件夹,但我无法通过 Hive 使用:

hive> show databases;

基本上,即使所有数据库文件夹都放置在正确的路径中,在 Hive 中我只能看到通过 Hive 创建的数据库,而在 R 中我只能看到通过 R 创建的数据库。

【问题讨论】:

    标签: r hadoop hive sparklyr


    【解决方案1】:

    我解决了在文件 hive-site.xml 中添加配置以与 hive 连接的问题:

       <property>
        <name>hive.metastore.uris</name>
        <value>thrift://localhost:9083</value>
      </property>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-01
      • 2014-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多