我在Big Query的“香蕉”列中有一句话“我想买香蕉”。
我想获得“我想购买香蕉”。我怎么了当我看到LOWER和UPPER时,我期待的是PROPER(Bananas)函数,但似乎不支持PROPER大小写吗?
DZ
最佳答案
下面的示例来自BigQuery Standard SQL
#standradSQL
CREATE TEMP FUNCTION PROPER(str STRING) AS ((
SELECT STRING_AGG(CONCAT(UPPER(SUBSTR(w,1,1)), LOWER(SUBSTR(w,2))), ' ' ORDER BY pos)
FROM UNNEST(SPLIT(str, ' ')) w WITH OFFSET pos
));
WITH `project.dataset.table` AS (
SELECT 'i Want to buy bananas' str
)
SELECT str, PROPER(str) proper_str
FROM `project.dataset.table`
结果是Row str proper_str
1 i Want to buy bananas I Want To Buy Bananas