Reputation: 13
I have a table with column named path
which contains values with backslash:
\ModuleCalData\ComputerName
\ModuleCalData\StartTime
\ModuleCalData\EndTime
\ModuleCalData\SummaryParameters\TextMeasured\Value
\ModuleCalDataSummaryParameters\TextMeasured\Name
I'm trying to split and access each element separately. The query is
select split(path,'\\')[0] from test_data_tag;
This query is erroring out
Failed with exception
java.io.IOException:org.apache.hadoop.hive.ql.metadata.HiveException:
Error evaluating split(path, '\')[0]
Can anyone help how to split the string on \
in hive?
Upvotes: 1
Views: 2116
Reputation: 44921
select path
,split(path,'\\\\') as split_path
from mytable
;
+-----------------------------+-------------------------------------+
| path | split_path |
+-----------------------------+-------------------------------------+
| \ModuleCalData\ComputerName | ["","ModuleCalData","ComputerName"] |
+-----------------------------+-------------------------------------+
Upvotes: 2