我如何使用 pyspark 显示配置单元表

发布于 2025-01-09 01:32:56 字数 99 浏览 5 评论 0原文

你好,我在 azure 上创建了一个 Spark HD Insight 集群,我正在尝试使用 pyspark 读取配置单元表,但问题是它只向我显示默认数据库

有人知道吗?

Hello i created a spark HD insight cluster on azure and i’m trying to read hive tables with pyspark but the proble that its show me only default database

Anyone have an idea ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

天冷不及心凉 2025-01-16 01:32:57

您在 SparkSession 中缺少配置单元服务器的详细信息。如果您没有添加任何内容,它将创建并使用默认数据库来运行sparksql。

如果您已在spark默认conf文件中添加了spark.sql.warehouse.dir和spark.hadoop.hive.metastore.uris的配置详细信息,则在创建SparkSession时添加enableHiveSupport()。

否则在创建 SparkSession 时添加配置详细信息

.config("spark.sql.warehouse.dir","/user/hive/warehouse")
.config("hive.metastore.uris","thrift://localhost:9083")
.enableHiveSupport()

You are missing details of hive server in SparkSession. If you haven't added any it will create and use default database to run sparksql.

If you've added configuration details in spark default conf file for spark.sql.warehouse.dir and spark.hadoop.hive.metastore.uris then while creating SparkSession add enableHiveSupport().

Else add configuration details while creating sparksession

.config("spark.sql.warehouse.dir","/user/hive/warehouse")
.config("hive.metastore.uris","thrift://localhost:9083")
.enableHiveSupport()
别把无礼当个性 2025-01-16 01:32:56

如果您使用 HDInsight 4.0,Spark 和 Hive 不再共享元数据。

默认情况下,您不会看到来自 pyspark 的配置单元表,这是我在这篇文章中分享的一个问题:如何在 hive 中保存/更新表,以便在 Spark 上读取

但是,无论如何,您可以尝试以下操作:

  1. 如果您只想在头节点上进行测试,您可以更改 hive-site.xml,在属性 "metastore.catalog.default" 上,将值更改为 < strong>hive,然后从命令行打开 pyspark。
  2. 如果要应用到所有集群节点,需要在 Ambari 上进行更改。
    • 以管理员身份登录 ambari
    • 转到spark2>配置>配置单元站点覆盖
    • 再次将属性“metastore.catalog.default”更新为hive
    • 重新启动 Ambari 面板上所需的所有内容

这些更改将 hive 元存储目录定义为默认值。
您现在可以看到 Hive 数据库和表,但根据表结构,您将无法正确看到表数据。

If you are using HDInsight 4.0, Spark and Hive not share metadata anymore.

For default you will not see hive tables from pyspark, is a problem that i share on this post: How save/update table in hive, to be readbale on spark.

But, anyway, things you can try:

  1. If you want test only on head node, you can change the hive-site.xml, on property "metastore.catalog.default", change the value to hive, after that open pyspark from command line.
  2. If you want to apply to all cluster nodes, changes need to be made on Ambari.
    • Login as admin on ambari
    • Go to spark2 > Configs > hive-site-override
    • Again, update property "metastore.catalog.default", to hive value
    • Restart all required on Ambari panel

These changes define hive metastore catalog as default.
You can see hive databases and table now, but depending of table structure, you will not see the table data properly.

蘸点软妹酱 2025-01-16 01:32:56

如果您已在其他数据库中创建了表,请尝试显示database_name 中的表。将 database_name 替换为实际名称。

If you have created tables in other databases, try show tables from database_name. Replace database_name with the actual name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文