如何将两个带有附加词的字符串连接到 HIVE 中的列值

How to concat two string with addon word to the column value in HIVE

我正在尝试使用 concat 和 concat_ws 函数连接两列。除了连接两列之外,我还想在此连接中附加一个词。所以我试着用下面的方法来实现

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 的方法,但遇到了语法问题。

问题是分号,它中断了查询。尝试用 3 替换分号,双反斜杠也可能有效 \;

而且似乎单个连接就足够了。

使用 3 的演示:

with test as (
select 12134.12345 as longitude, 12134.12345 as latitude
)

SELECT CONCAT("SRID=43263POINT(", 
               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)