【问题标题】:Hive table is not shown when using Sparklyr使用 Sparklyr 时未显示 Hive 表
【发布时间】:2020-03-26 12:54:10
【问题描述】:

我正在尝试复制this tutorial from RStudio website

当我将数据加载到 Hive 中时,我可以在 Hive 命令行中运行 show tablesselect count(*) from airlines,我会得到正确的响应。但是在教程的后面,当我安装sparklyr 并使用下面的命令连接到数据时,RStudio 的 Connections 选项卡中没有显示任何表。

sc <- spark_connect(master = "yarn-client", config = config, version = '2.4.4')

此外,令人惊讶的是,当我运行 hive_context(sc) %&gt;% invoke('sql', 'show tables') %&gt;% collect() 时,我没有得到任何表格;就好像 Spark 正在连接到不同的 Hive 实例。

例如,如果我运行以下命令将表添加到 Hive 数据库,它将显示在 Connections 选项卡上,并且当我将 show tables 作为 SQL 命令运行时,它将被列出。

iris_tbl <- copy_to(sc, iris, "iris", overwrite = TRUE)
hive_context(sc) %>% invoke('sql', 'show tables') %>% collect()
# A tibble: 1 x 3
  database tableName isTemporary
  <chr>    <chr>     <lgl>      
1 NA       iris      TRUE  

但是当我通过终端进入 Hive 命令行并运行 show tables; 时,它不会显示 iris 表。

如何告诉 Spark 连接到“正确”的 Hive 实例?

【问题讨论】:

    标签: r apache-spark hive rstudio sparklyr


    【解决方案1】:

    您使用的是哪个环境?对于 sparklyr 1.0.4+,如果您在 hadoop 2.6x 上运行,则需要手动设置 spark sql 目录实现。您可以尝试添加 spark.sql.catalogImplementation: "hive"

    您的代码最终可能如下所示:

    config <- spark_config()
    config$spark.sql.catalogImplementation <- "hive"
    
    sc <- spark_cconnect(master="yarn", config=config, version=...)
    

    【讨论】:

      猜你喜欢
      • 2017-09-02
      • 2013-10-30
      • 2019-03-21
      • 2017-11-23
      • 2017-05-23
      • 1970-01-01
      • 2020-04-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多