首页 > 解决方案 > 字符串连接运算符(||)在配置单元中抛出错误

问题描述

我正在尝试使用 concat 运算符 || 连接表中的字符串列 并抛出错误。

Here is the query: select "Bob"||'~'||"glad" from table

its throwing error as : ParseException - cannpt recognize input near '|' '"~"' '|' in expression specification

它适用于 concat 函数,但不适用于 concat 运算符。

select concat("bob","~","glad") from table - its working

我正在使用 hive 2.1 版,谁能告诉我为什么这个操作员不起作用?

谢谢,巴布

标签: apache-sparkhadoophivehiveql

解决方案


Hive 不支持 concat 运算符||,它的 oracle 语法。请使用concat函数连接多个值。您可以使用concat_ws与分隔符连接。
连接

select concat ('this','~','is','~','hello','~','world');
Output : this~is~hello~world
select concat_ws ('~','hello','world','is','not','enough');
Output : hello~world~is~not~enough

推荐阅读