簡體   English   中英

AWS Athena:正確的功能

[英]AWS Athena: Right function

我想right從 AWS athena 使用該功能,但似乎不受支持。

我將如何處理和修剪 Athena 中的某些角色?

例如我想做RIGHT('1313521521', 4)

得到1521 不幸的是,我會得到類似的東西

Queries of this type are not supported

Athena 使用 Presto 作為 SQL 引擎,它沒有right功能,但是您可以使用substr來模仿它並確定greatest(length(str) - 3, 1) - 我們需要從最后一個索引的第 4 個開始,如果是字符串太短 - 從第一個索引開始,導致 Presto 索引從 1) 開始:

--sample data
with dataset(str) as (
    VALUES ('id1'),
    ('1313521521'),
    ('')
)

-- query
select substr(str, greatest(length(str) - 3, 1))
from dataset

輸出:

_col0
id1
1521

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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