Skip to content

Latest commit

 

History

History
70 lines (40 loc) · 2.79 KB

20230928_10.md

File metadata and controls

70 lines (40 loc) · 2.79 KB

DuckDB 语法糖: List lambda functions

作者

digoal

日期

2023-09-28

标签

PostgreSQL , PolarDB , duckdb , 语法糖


背景

duckdb增加了很多SQL语法糖, 目标是要让用户可以随心所欲的写SQL.

https://duckdb.org/2023/08/23/even-friendlier-sql.html

List lambda functions

转换

SELECT   
     (['Enterprise NCC-1701', 'Voyager NCC-74656', 'Discovery NCC-1031'])  
          .list_transform(x -> x.string_split(' ')[1]) AS short_name;  
ship_name  
[Enterprise, Voyager, Discovery]  

匹配

SELECT   
     (['Enterprise NCC-1701', 'Voyager NCC-74656', 'Discovery NCC-1031'])  
          .list_filter(x -> x.contains('1701')) AS the_original;  
the_original  
[Enterprise NCC-1701]  

digoal's wechat