保存数据框星火在蜂巢动态分区表 [英] Save Spark dataframe as dynamic partitioned table in Hive

查看:394
本文介绍了保存数据框星火在蜂巢动态分区表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个示例应用程序的工作从CSV文件读入数据帧。数据框可以使用方法来存储到一个蜂巢表格式的实木复合地板
df.saveAsTable(表名,模式)的。

I have a sample application working to read from csv files into a dataframe. The dataframe can be stored to a Hive table in parquet format using the method df.saveAsTable(tablename,mode).

以上code正常工作,但我每天这么多的数据,我想动态分区基础上,creationdate蜂箱表(表中的列)。

The above code works fine, but I have so much data for each day that i want to dynamic partition the hive table based on the creationdate(column in the table).

有没有什么办法来动态分区数据框,并将其存储到仓库蜂房。要从硬编码使用INSERT语句的 hivesqlcontext.sql不要(按(日期插入到表partittioin)....)

is there any way to dynamic partition the dataframe and store it to hive warehouse. Want to refrain from Hard-coding the insert statement using hivesqlcontext.sql(insert into table partittioin by(date)....).

问题可被认为是一个扩展:<一href=\"http://stackoverflow.com/questions/30664008/how-to-load-dataframe-directly-to-hive-in-spark\">How加载数据帧直接向蜂巢在星火

Question can be considered as an extension to :How to load DataFrame directly to Hive in Spark

任何帮助很多AP preciated。

any help is much appreciated.

推荐答案

我相信它的工作原理是这样的:

I believe it works something like this:

东风是年,月,其他列的数据帧

df is a dataframe with year, month and other columns

df.write.partitionBy('year', 'month').saveAsTable(...)

df.write.partitionBy('year', 'month').insertInto(...)

这篇关于保存数据框星火在蜂巢动态分区表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆