如何使用 Java 连接到 spark 中的配置单元数据库
How to connect to hive databases in spark Using Java
我可以在 Sparksession 中使用 hive.metastore.uris
连接到配置单元。我想要的是使用此连接连接到特定的配置单元数据库,这样我就不需要在查询中为每个 table 名称添加数据库名称。有什么办法可以实现吗?
期待类似
的代码
SparkSession sparkSession = SparkSession.config("hive.metastore.uris", "thrift://dhdhdkkd136.india.sghjd.com:9083/hive_database")
您可以使用可从 SparkSession 访问的目录 API。
https://spark.apache.org/docs/latest/api/scala/index.html#org.apache.spark.sql.catalog.Catalog
然后您可以调用 sparkSession.catalog.setCurrentDatabase(<db_name>)
我可以在 Sparksession 中使用 hive.metastore.uris
连接到配置单元。我想要的是使用此连接连接到特定的配置单元数据库,这样我就不需要在查询中为每个 table 名称添加数据库名称。有什么办法可以实现吗?
期待类似
的代码SparkSession sparkSession = SparkSession.config("hive.metastore.uris", "thrift://dhdhdkkd136.india.sghjd.com:9083/hive_database")
您可以使用可从 SparkSession 访问的目录 API。
https://spark.apache.org/docs/latest/api/scala/index.html#org.apache.spark.sql.catalog.Catalog
然后您可以调用 sparkSession.catalog.setCurrentDatabase(<db_name>)