我有一个名为path
的列的表,其中包含带反斜杠的值:
\ModuleCalData\ComputerName
\ModuleCalData\StartTime
\ModuleCalData\EndTime
\ModuleCalData\SummaryParameters\TextMeasured\Value
\ModuleCalDataSummaryParameters\TextMeasured\Name
我正在尝试拆分并分别访问每个元素。查询是
select split(path,'\\')[0] from test_data_tag;
此查询错误输出
异常时失败 产生java.io.IOException:org.apache.hadoop.hive.ql.metadata.HiveException:
评估拆分时出错(路径,'\')[0]
任何人都可以帮助如何拆分hive中\
的字符串吗?
答案 0 :(得分:2)
select path
,split(path,'\\\\') as split_path
from mytable
;
+-----------------------------+-------------------------------------+
| path | split_path |
+-----------------------------+-------------------------------------+
| \ModuleCalData\ComputerName | ["","ModuleCalData","ComputerName"] |
+-----------------------------+-------------------------------------+