来自 sparklyr 的非默认方案(数据库)中的访问表 [英] Access table in other than default scheme (database) from sparklyr
本文介绍了来自 sparklyr 的非默认方案(数据库)中的访问表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我使用 sparklyr
和 yarn-client
方法管理它连接到我们的(新)集群后,现在我可以只显示默认方案中的表.如何连接到 scheme.table
?使用 DBI
它正在工作,例如与以下行:dbGetQuery(sc, "SELECT * FROM scheme.table LIMIT 10")
在 HUE 中,我可以显示所有方案的所有表.
After I managed it to connect to our (new) cluster using sparklyr
with yarn-client
method, now I can show just the tables from the default scheme. How can I connect to scheme.table
?
Using DBI
it's working e.g. with the following line:
dbGetQuery(sc, "SELECT * FROM scheme.table LIMIT 10")
In HUE, I can show all tables from all schemes.
~g
推荐答案
您可以使用完全限定名称来注册临时视图:
You can either use a fully qualified name to register temporary view:
spark_session(sc) %>%
invoke("table", "my_database.my_table") %>%
invoke("createOrReplaceTempView", "my_view")
tbl(sc, "my_view")
或使用sql
方法切换数据库
spark_session(sc) %>% invoke("sql", "USE my_database")
并直接使用 dplyr:tbl
:
tbl(sc, "my_table")
这篇关于来自 sparklyr 的非默认方案(数据库)中的访问表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文