如何使用反映HIVE的替换字符串? [英] How to use a replace string with reflect in HIVE?
本文介绍了如何使用反映HIVE的替换字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I want to replace a string from "\7" to "\1", my input file like this:
a\7b\7c\7
c> a\7b\7c\7
my other table FIELDS TERMINATED BY '\001', so I must replace "\7" to "\1".
我的另一张桌子FIELDS TERMINATED BY'\ 001',所以我必须将\7替换为\ 1。
我试过了
I tried
select regexp_replace(value, "\\u0007", "\\u0001") from test_tbl where dbs="test" and dt=20131130;
但它不起作用。
我写了一个php脚本,如下所示:
And I wrote a php script like this:
<?php
$strCmd = "hive -e 'select regexp_replace(value, \"\\u0007\", \"\1\") from test_tbl where dbs=\"test\" and dt=20131130;' > tmp";
exec($strCmd);
但它会返回一些错误。
but it return some error.
推荐答案
我用 transform 方法,我写了一个包含str_replace的简单php脚本。但是我发现了另一个issus,请参阅。
I solved it with "transform" method and I wrote a simple php script that contains str_replace. But I found another issus, see here.
感谢所有人帮助我。
这篇关于如何使用反映HIVE的替换字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文