datafuselabs / databend

𝗗𝗮𝘁𝗮, 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 & 𝗔𝗜. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.66k stars 726 forks source link

Feature: copy support transform clause #16084

Open youngsofun opened 1 month ago

youngsofun commented 1 month ago

Summary

copy into <dest_table> from <location> transform (<col_name1> <expr1>, <col_name2> <expr2>,)

suppose table1 has 100 columns. user want to transform 2 columns. he can just use

copy into table1 from @stage1 transform (c3  if(c3 <0,  0, c3), c80 trim(c80))

instead of

copy into table1 from @stage1 from (select c1, c2,  if(c3 <0,  0, c3), ....   trim(c80) .... from @stage1)
youngsofun commented 1 month ago

cc @wubx

wubx commented 1 month ago

This is a bit complicated, I think the Query stage will do.

copy into o table1 from (select $1,$2, if($3<0,0,c3) from @stage) file_format=(type=csv compression=auto) purge=true;