我有一个名为path的表,其中包含带有反斜杠的值:

\ModuleCalData\ComputerName
\ModuleCalData\StartTime
\ModuleCalData\EndTime
\ModuleCalData\SummaryParameters\TextMeasured\Value
\ModuleCalDataSummaryParameters\TextMeasured\Name

我正在尝试分别拆分和访问每个元素。查询是
select split(path,'\\')[0] from test_data_tag;

该查询错误



谁能帮助在 hive 中分割\上的字符串?

最佳答案

select path
      ,split(path,'\\\\')   as split_path

from   mytable
;
+-----------------------------+-------------------------------------+
|             path            |              split_path             |
+-----------------------------+-------------------------------------+
| \ModuleCalData\ComputerName | ["","ModuleCalData","ComputerName"] |
+-----------------------------+-------------------------------------+

10-08 05:40