9月 162020
 

总是需要写一些transform放在hive上也挺麻烦,尤其这个transform还需要复杂的配置文件或者是访问IP首先等情况,还不见得能跑通,于是,我就发明了一个万能的transform:

只需要在自己喜欢的机器上执行命令行程序就行,使用nc来做这个万能的transform,然而,自己的程序总是需要listen一个端口是不是也很麻烦,其实不难:

办法1:

使用 nc -l 10.210.227.25 1234 -e “your-command”

办法2: 如果你的nc版本太低,还不支持-e

把这个编译一下,类似于nc的作用

 

注意:

使用transform时要注意:

虽然这了有limit 10 ,你的transform干的可能不是10个的活儿,哪怕这个table只有一个file,可能和执行这个任务用到的机器数量有关;从这个角度来看,hive还不够聪明;

可能需要自己优化一下:

 

transform 只能靠进程数量提高效率,没法在进程内并发?这个不担心乱序?

可以设置reducer的数量来限制并发。

transform的输出格式:

If there is no AS clause after USING my_script, Hive assumes that the output of the script contains 2 parts: key which is before the first tab, and value which is the rest after the first tab. Note that this is different from specifying AS key, value because in that case, value will only contain the portion between the first tab and the second tab if there are multiple tabs.

如果transform子句的using 后面没有as子句:

则输出被视为以第一个tab为分隔的两列,第一列是key,第二列是value;如果输出中没有tab,则整行都是第一列,第二列就是NULL;如果输出中有tab,则第一个tab之前的是第一列,第一个tab以后的都视为第二列

如果transform子句的using 后面有as子句:

则按照tab分隔视为多列

 

参考:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Transform

 

 Posted by at 下午 5:16

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据