0

如何进行简单的数据操作或丰富?

通常,在管道中,您使用 DataFlow 作业,但 Cloud Workflows 中是否有选项可以执行此类操作?

4

1 回答 1

0

您可以通过声明 aDictionary并重用以随时随地收集东西来实现此功能。

需要注意的是,当您添加新值时,您需要再次重新键入所有键,因为变量引用、合并键或 YAML 锚尚未实现。

因此,如果您从以下内容开始:

- initDictionary:
    assign:
      - myDictionary:
          name: John
          lastName: Smith
          dayOfTheWeek: ${currentTime.body.dayOfTheWeek}

您可以稍后从另一个结果中添加一个键,例如来自维基百科,如下所示:

- enrichStep:
    assign:
      - myDictionary:
          name: ${myDictionary.name}
          lastName: ${myDictionary.lastName}
          dayOfTheWeek: ${currentTime.body.dayOfTheWeek}
          wikiResult: ${wikiResult.body[1]}

这是给你的完整wikipedia_enrichment.yaml序列。

- getCurrentTime:
    call: http.get
    args:
        url: https://us-central1-workflowsample.cloudfunctions.net/datetime
    result: currentTime
- initDictionary:
    assign:
      - myDictionary:
          name: John
          lastName: Smith
          dayOfTheWeek: ${currentTime.body.dayOfTheWeek}
- readWikipedia:
    call: http.get
    args:
        url: https://en.wikipedia.org/w/api.php
        query:
            action: opensearch
            search: ${currentTime.body.dayOfTheWeek}
    result: wikiResult
- enrichStep:
    assign:
      - myDictionary:
          name: ${myDictionary.name}
          lastName: ${myDictionary.lastName}
          dayOfTheWeek: ${currentTime.body.dayOfTheWeek}
          wikiResult: ${wikiResult.body[1]}
- returnResult:
    return: ${myDictionary}
于 2020-12-02T20:51:21.627 回答