代码之家  ›  专栏  ›  技术社区  ›  MAK

获取以Cosmos为源的Azure数据工厂中时间戳的最后一个值

  •  0
  • MAK  · 技术社区  · 7 年前

    我的管道有两个测试活动。一个查找活动和一个存储过程,它只接受查找的输出,然后将其用作参数来执行。

    我想在我正在编写的查询中获取字段的最大值(comos-db-unix时间戳)。

    enter image description here

    这是我对来源的查询:

    select max(c._ts) AS UnixTimestamp  from c 
    where udf.convertTime(c._ts) >= '@{formatDateTime(addhours(pipeline().TriggerTime, -1), 'yyyy-MM-ddTHH:mm:ssZ' )}' 
    AND udf.convertTime(c._ts) < '@{formatDateTime(pipeline().TriggerTime, 'yyyy-MM-ddTHH:mm:ssZ' )}'
    

    调试时,这是转换后的输入:

    {
        "source": {
            "type": "DocumentDbCollectionSource",
            "query": "select max(c._ts) AS UnixTimestamp  from c \nwhere udf.convertTime(c._ts) >= '2018-11-06T18:19:56Z' \nAND udf.convertTime(c._ts) < '2018-11-06T19:19:56Z'",
            "nestingSeparator": "."
        },
        "dataset": {
            "referenceName": "SourceComosDB",
            "type": "DatasetReference",
            "parameters": {}
        },
        "firstRowOnly": false
    }
    

    查找活动的输出结果是:

    {
        "count": 18,
        "value": [
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {}
        ],
        "effectiveIntegrationRuntime": "DefaultIntegrationRuntime (East US 2)"
    }
    

    因此不执行存储过程。

    如何获取查询中的最大值?

    1 回复  |  直到 6 年前
        1
  •  1
  •   halfer Jatin Pandey    6 年前

    我测试了您的代码,没有重现您的问题。

    我的示例代码:

    enter image description here

    使用SQL查找活动输出:

    enter image description here

    使用SQL查找活动输出:

    enter image description here

    有一点,它不能输出 18 如果您使用 MAX 查询,应该只是一个值。

    另外,您应该在cosmos-db查询编辑器中执行sqk,以查看是否有任何结果与过滤器匹配。