You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Azure Data Factory抽取Yahoo Finance API数据时的Flatten超时问题

解决Azure Data Factory中Yahoo Finance JSON扁平化超时问题

核心问题分析

Yahoo Finance API返回的JSON结构里,timestamp与open/high/low/close/volume是平行数组,直接用默认Flatten配置容易因数组关联逻辑不当触发超时,加上分区设置不合理会放大这个问题。

分步解决方案

1. 调整Flatten活动的分区策略

  • 把Flatten活动的Partition option从Use current partitioning改成Single partition。单只股票的API返回数据量不大,单分区处理能避免多分区调度的额外开销,直接缓解超时问题。

2. 按JSON结构分步转换

步骤1:解析原始JSON

用Parse转换将HTTP数据源返回的原始JSON字符串解析为结构化对象,确保正确提取chart.result数组:

  • 解析路径设为$(根节点),输出结构选Document form。

步骤2:展开chart.result数组

第一次用Flatten转换,展开chart.result数组,得到包含timestamp和indicators的单条记录:

  • 设置Unroll by为chart.result,此时输出会包含timestamp(数组)、indicators.quote[0].open(数组)、indicators.quote[0].high(数组)等字段。

步骤3:生成数组索引关联列

用Derived Column转换生成数组的索引序列,确保timestamp和行情数组的元素一一对应:

  • 添加列indexes,表达式写:range(0, size(timestamp), 1)
  • 注:Yahoo返回的timestamp与行情数组长度完全一致,用同一个索引即可关联。

步骤4:扁平化数组并关联索引

第二次用Flatten转换,同时展开timestamp、行情数组和索引列:

  • 设置Unroll by为indexes
  • 在Unroll root中添加以下映射:
    • timestampItem = timestamp[indexes]
    • openItem = indicators.quote[0].open[indexes]
    • highItem = indicators.quote[0].high[indexes]
    • lowItem = indicators.quote[0].low[indexes]
    • closeItem = indicators.quote[0].close[indexes]
    • volumeItem = indicators.quote[0].volume[indexes]

步骤5:清理并重命名列

用Select转换保留需要的字段并重命名:

  • 保留timestampItem(重命名为timestamp)、openItem(重命名为open)、highItem(重命名为high)、lowItem(重命名为low)、closeItem(重命名为close)、volumeItem(重命名为volume)。

3. 额外超时优化措施

  • 在数据流调试设置里,把Row limit设为50-100,减少预览时的数据处理量。
  • 检查HTTP链接服务的超时设置,将Timeout调整为300秒(默认值可能偏短)。
  • 分步预览每个转换环节的结果,排查是否有字段路径错误导致无效计算。

内容的提问来源于stack exchange,提问作者Carolina Karoullas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 23:10:58