簡體   English   中英

如何將帶有附加詞的兩個字符串連接到 HIVE 中的列值

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM