apache-spark - 通过 spark 在 hive 中创建表
问题描述
我正在尝试使用以下代码通过 Spark 连接到 Hive,但无法这样做。代码失败,NoSuchDatabaseException Database 'raw' not found。我在 hive 中有名为“raw”的数据库。我在这里想念什么?
val spark = SparkSession
.builder()
.appName("Connecting to hive")
.config("hive.metastore.uris", "thrift://myserver.domain.local:9083")
.enableHiveSupport()
.getOrCreate()
import spark.implicits._
import spark.sql
val frame = Seq(("one", 1), ("two", 2), ("three", 3)).toDF("word", "count")
frame.show()
frame.write.mode("overwrite").saveAsTable("raw.temp1")
spark.sql("SHOW DATABASES") 的输出
解决方案
推荐阅读
- stack-trace - 如何在使用 retrace.jar 去混淆的 android / R8 堆栈跟踪中读取 lambda?
- sql - PostgreSQL 复合外键“列列表不得包含重复项”
- database - 如何在wordpress中运行代码来处理数据库
- python - 如何将逗号分隔的数字字符串转换为数字?
- python - 如何使用于转义字符串中字符的反斜杠不计数
- javascript - 从数组中提取值的意外行为:所有值都是 2
- graphql - 为 React Admin 3.7 实现 GraphQL 数据提供程序
- asp.net-core - JWT 在 .NET Core Web API 中过期太快
- angular - 是否在延迟加载模块时创建 2 个服务实例
- java - 在 Java 中使用序列化和反序列化时如何处理类更改