在猪/蜂巢中操作数据结构 [英] Manipulating a data structure in Pig/Hive

查看:203
本文介绍了在猪/蜂巢中操作数据结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不太确定如何解决这个问题,所以请重新定位我,如果这个问题有一个更好的地方。

I'm not really sure how to phrase this question, so please redirect me if there is a better place for this question.

现在我有一个数据结构,或多或少组织如下:

Right now I have a data structure, more or less organized like this:

我希望我的数据看起来像这样:

I want my data to look like this:

对于图像,显然我不能使用markdown来做这些!

我意识到我的问题类似于这一个,但理想情况下,我希望能够在猪,但知道如何在Hive,R,Python或Excel / LibreCalc中执行此操作也将是有用的/有趣的。

I realize my question is similar to this one, but ideally I would like to be able to do this in Pig, but knowing how to do it in Hive, R, Python, or Excel/LibreCalc would be useful/interesting too.

我甚至不知道这种数据操作被称为,所以指导我去某种一般的维基页面将是有帮助的。

I'm not even sure what this kind of data manipulation is called, so directing me to some sort of general wiki page would be helpful.

推荐答案

@vkp让我从正确的方向开始,但是我不得不添加一些调整来使其在Hive上工作:

@vkp got me started in the right direction, but I had to add a few tweaks to get it working on Hive:

CREATE TABLE myDatabase.newTable STORED AS TEXTFILE AS 
SELECT item, year, 'jan' AS Month, jan AS Value FROM myDatabase.myTable UNION ALL
SELECT item, year, 'feb' AS Month, feb AS Value FROM myDatabase.myTable UNION ALL
SELECT item, year, 'mar' AS Month, mar AS Value FROM myDatabase.myTable;

仍然对一种适用于Pig的解决方案感兴趣。

Still interested in a solution that works on Pig.

这篇关于在猪/蜂巢中操作数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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