Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hive 如何在配置单元中使用带有反射的替换字符串?_Hive - Fatal编程技术网

Hive 如何在配置单元中使用带有反射的替换字符串?

Hive 如何在配置单元中使用带有反射的替换字符串?,hive,Hive,我想将字符串从“\7”替换为“\1”,我的输入文件如下: a\7b\7c\7 <?php $strCmd = "hive -e 'select regexp_replace(value, \"\\u0007\", \"\1\") from test_tbl where dbs=\"test\" and dt=20131130;' > tmp"; exec($strCmd); 我的其他表字段以“\001”结尾,因此我必须将“\7”替换为“\1” 我试过了 select regexp

我想将字符串从“\7”替换为“\1”,我的输入文件如下:

a\7b\7c\7
<?php
$strCmd = "hive -e 'select regexp_replace(value, \"\\u0007\", \"\1\") from test_tbl where dbs=\"test\" and dt=20131130;' > tmp";
exec($strCmd);
我的其他表字段以“\001”结尾,因此我必须将“\7”替换为“\1”

我试过了

select regexp_replace(value, "\\u0007", "\\u0001") from test_tbl where dbs="test" and dt=20131130;
但它不起作用

我编写了一个php脚本,如下所示:

a\7b\7c\7
<?php
$strCmd = "hive -e 'select regexp_replace(value, \"\\u0007\", \"\1\") from test_tbl where dbs=\"test\" and dt=20131130;' > tmp";
exec($strCmd);

对于配置单元中的替换,您可以使用以下查询

select regexp_replace(value, "\\u0007", "\\u0001") from test_tbl where dbs="test" and dt=20131130;
反射在配置单元中用于调用静态函数。因此,字符串替换可能不起作用。在这里我找到了一些你要找的信息。

您可以尝试使用reflect2 UDF

编辑:

如果输入的纯文本为“\7”而不是某些ascii字符,则下面的查询应该可以工作

select regexp_replace(value, "\\\\7", "\\\\1") from test_tbl where dbs="test" and dt=20131130;
我用“”方法解决了这个问题,并编写了一个包含str_replace的简单php脚本。但我发现了另一个问题,看


感谢所有帮助我的人。

我尝试了一下,它可以正确地找到“\7”,但它会将其替换为“u0001”。我尝试\u0001,结果是一样的。我编写了一个php脚本并直接写入“\1”,但hive返回了一个错误“org.apache.hadoop.ipc.RemoteException:java.io.IOException:java.lang.RuntimeException:org.xml.sax.SAXParseException:Character reference”“是一个无效的xml字符。”一旦检查了这些,我就不确定为什么会出现错误。你能告诉我你到底想做什么吗。输入文件包含的内容。可能是PHP,unicode的引用不同。看这篇文章@moreforeze check我更新了我的答案。如果这不起作用,请告诉我。我复制了你的cmd并运行它,但它似乎和origin一样,它什么也不替换。真奇怪。