[英]How to concat two string with addon word to the column value in HIVE
我正在尝试使用 concat 和 concat_ws function 连接两列。 除了连接两列之外,我还想 append 对这个连接说一句话。 所以我尝试使用下面的方法来实现
SELECT CONCAT(CONCAT("SRID=4326;POINT(", CONCAT_WS(" ",cast(A.longitude as string),cast(A.latitude as string))), ")") as the_geom
FROM test
使用上述语法,我收到以下错误。
**org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: FAILED: ParseException line 1:13 cannot recognize input near 'CONCAT' '(' 'CONCAT' in expression specification**
我不知道我在上面的语法中做错了什么。 有没有其他方法可以实现这一目标。
预期结果: SRID=4326;POINT(127.155104 35.8091378)
我尝试了所有使用 concat 和 concat_ws 的方法,但遇到了语法问题。
问题是分号,它破坏了查询。 尝试用\073
替换分号,双反斜杠也可以工作\\;
此外,似乎单个 concat 就足够了。
使用\073
演示:
with test as (
select 12134.12345 as longitude, 12134.12345 as latitude
)
SELECT CONCAT("SRID=4326\073POINT(",
CONCAT_WS(" ",cast(A.longitude as string),cast(A.latitude as string))
, ")"
) as the_geom
FROM test A
结果:
SRID=4326;POINT(12134.12345 12134.12345)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.