Azure Synapse Data Flow,如何在数组中删除字段。

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

Azure Synapse Data flow, how to drop a field within an array

问题

希望删除数组中对象的字段在 synapse 数据流中。

示例数据:

"Animals":[{"name":"tiger","colour":"white","location":"zoo"},{"name":"eagle","colour":"brown","location":"wild"}]

预期输出:

"Animals":[{"name":"tiger","location":"zoo"},{"name":"eagle","location":"wild"}]

英文:

Looking to drop a field from an array of objects in synapse data flows.

Example data:

"Animals":[{"name":"tiger","colour":"white","location":"zoo"},{"name":"eagle","colour":"brown","location":"wild"}]

Expected Output:

"Animals":[{"name":"tiger","location":"zoo"},{"name":"eagle","location":"wild"}]

Looking for a way to drop the field. Thanks very much!

答案1

得分: 0

  • 您可以使用数据流和复制活动来实现您的要求。我已经使用了以下配置的展平转换:

Azure Synapse Data Flow,如何在数组中删除字段。

  • 这将产生一些结果数据,我正在使用 sink 缓存将其写入数据流活动的输出。

Azure Synapse Data Flow,如何在数组中删除字段。

  • 在管道中,在数据流活动后面加入了一个复制数据活动,源文件如下(1 行和 1 列,无论如何都会被忽略)。

Azure Synapse Data Flow,如何在数组中删除字段。

  • 现在,按如下所示添加一个额外的列:
{"Animals":{@{activity('Data flow1').output.runStatus.output.sink1.Value}}}

Azure Synapse Data Flow,如何在数组中删除字段。

  • 现在,选择以分隔文件的形式的接收器文件,并使用以下配置:

Azure Synapse Data Flow,如何在数组中删除字段。

  • 在映射中,仅保留上面创建的额外列,并删除其余部分。

Azure Synapse Data Flow,如何在数组中删除字段。

  • 当您运行管道时,将按所需获取数据。您可以创建一个 JSON 数据集,并使用此文件作为 JSON 文件。

Azure Synapse Data Flow,如何在数组中删除字段。

英文:
  • You can use a dataflow and copy activity to achieve your requirement. I have used a flatten transformation with following configuration:

Azure Synapse Data Flow,如何在数组中删除字段。

  • This would give some resulting data which I am writing to dataflow activity output using sink cache.

Azure Synapse Data Flow,如何在数组中删除字段。

  • In the pipeline, I have taken a copy data activity after the dataflow activity with source file as follows (1 row and 1 column which will be ignored anyway).

Azure Synapse Data Flow,如何在数组中删除字段。

  • Now, add an additional column as shown below:
{"Animals":@{activity('Data flow1').output.runStatus.output.sink1.Value}}

Azure Synapse Data Flow,如何在数组中删除字段。

  • Now, choose sink file as delimited file with following configurations:

Azure Synapse Data Flow,如何在数组中删除字段。

  • In the mapping, keep only the above created additional column and delete the rest.

Azure Synapse Data Flow,如何在数组中删除字段。

  • When you run the pipeline, you would get the data as required. You can create a JSON dataset and use this file as a JSON file.

Azure Synapse Data Flow,如何在数组中删除字段。

huangapple
  • 本文由 发表于 2023年4月19日 23:55:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76056563.html
匿名

发表评论

匿名网友

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

确定