【发布时间】:2021-10-30 20:11:04
【问题描述】:
我的配置单元表具有以下结构
创建表 gcganamrswp_work.historical_trend_result(
列名字符串,
metric_name 字符串,
current_percentage 字符串,
lower_threshold 双倍,
双倍上限,
calc_status 字符串,
final_status 字符串,
support_override 字符串,
数据集名称字符串,
插入时间戳字符串,
appid 字符串,
当前日期字符串,
指标图
由 (
应用名称字符串,
year_month int)
存储为镶木地板
TBLPROPERTIES ("parquet.compression"="SNAPPY");
我有带有架构的 spark 数据框
root
|-- metric_name: string (nullable = true)
|-- column_name: string (nullable = true)
|-- Lower_Threshold: double (nullable = true)
|-- Upper_Threshold: double (nullable = true)
|-- Current_Percentage: double (nullable = true)
|-- Calc_Status: string (nullable = false)
|-- Final_Status: string (nullable = false)
|-- support_override: string (nullable = false)
|-- Dataset_Name: string (nullable = false)
|-- insert_timestamp: string (nullable = false)
|-- appId: string (nullable = false)
|-- currentDate: string (nullable = false)
|-- indicator: map (nullable = false)
| |-- key: string
| |-- value: string (valueContainsNull = false)
|-- appname: string (nullable = false)
|-- year_month: string (nullable = false)
当我尝试使用以下代码插入配置单元表时失败
spark.conf.set("hive.exec.dynamic.partition", "true")
spark.conf.set("hive.exec.dynamic.partition.mode", "nonstrict")
data_df.repartition(1)
.write.mode("append")
.format("hive")
.insertInto(Outputhive_table)
Spark 版本:Spark 2.4.0
错误:
ERROR Hive:1987 - 使用参数加载分区时出现异常 partPath=hdfs://gcgprod/data/work/hive/historical_trend_result/.hive-staging_hive_2021-09-01_04-34-04_254_8783620706620422928-1/-ext-10000/_temporary/0, table=historical_trend_result, partSpec={appname=, year_month=}, 替换=假,listBucketingEnabled=假,isAcid=假, hasFollowingStatsTask=false org.apache.hadoop.hive.ql.metadata.HiveException: MetaException(消息:分区规范不正确。{appname=, 年月=})在 org.apache.hadoop.hive.ql.metadata.Hive.loadPartitionInternal(Hive.java:1662) 在 org.apache.hadoop.hive.ql.metadata.Hive.lambda$loadDynamicPartitions$4(Hive.java:1970) 在 java.util.concurrent.FutureTask.run(FutureTask.java:266) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 在 java.lang.Thread.run(Thread.java:748) 引起: MetaException(消息:分区规范不正确。{appname=, 年月=})在 org.apache.hadoop.hive.metastore.Warehouse.makePartName(Warehouse.java:329) 在 org.apache.hadoop.hive.metastore.Warehouse.makePartPath(Warehouse.java:312) 在 org.apache.hadoop.hive.ql.metadata.Hive.genPartPathFromTable(Hive.java:1751) 在 org.apache.hadoop.hive.ql.metadata.Hive.loadPartitionInternal(Hive.java:1607)
我已经在数据框的最后一列中指定了分区列,所以我希望它将最后两列视为分区列。我想使用相同的例程来插入不同的表,所以我不想明确提及分区列
【问题讨论】:
-
可能是因为您的架构显示 year_mont int,但数据框显示的是 year_month 字符串?
标签: scala apache-spark hive