如何在数据融合中使用unnest函数

huangapple go评论41阅读模式
英文:

How to use unnest function in data fusion

问题

My input table is like this:

如何在数据融合中使用unnest函数

and I need output like this in data fusion (i.e if if qty=2 records need to repeated 2 times, if its 1 repeated once, if its n n times).

can you please any one help me in Cloud-datafusion what wrangler directive i can use to get the data in this format.

如何在数据融合中使用unnest函数

英文:

My input table is like this:

如何在数据融合中使用unnest函数

and I need output like this in data fusion (i.e if if qty=2 records need to repeated 2 times, if its 1 repeated once, if its n n times).

can you please any one help me in Cloud-datafusion what wrangler directive i can use to get the data in this format.

如何在数据融合中使用unnest函数

答案1

得分: 1

以下是翻译好的部分:

  • 使用以下指令来创建所需大小的列表,然后展开它并删除字段后:
  • set-column :arr l=new('java.util.ArrayList');i=0;while(i lt qty) {l.add(i);i=i+1}; return l;
  • flatten :arr
  • drop :arr

请注意,从单个行生成的整个行列表应适应执行器内存,因此适用于较小的数量(最多约1000个)。如果要处理更大的数量,您需要生成一个数据集并使用高级连接。

英文:

You can use next directives to create a list of needed size, then explode it and remove the field after:

  • set-column :arr l=new('java.util.ArrayList');i=0;while(i lt qty) {l.add(i);i=i+1}; return l;
  • flatten :arr
  • drop :arr

Please note that the whole list of rows produced from a single row should fit into executor memory, so it's practical for smaller quantities (up to ~1000). To go bigger numbers, you would need to generate a dataset and use an advanced join.

huangapple
  • 本文由 发表于 2023年7月10日 20:42:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76653852.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定