如何处理 ProgressPercentage 不返回 100 的情况?

发布于 2025-01-11 12:04:04 字数 1345 浏览 0 评论 0原文

我正在使用节点 @aws-sdk/client-timestream-query 3.53.0 包。我遇到了一个问题,ProgressPercentage 的结果不是 100,而是返回了承诺。


    const promise = this.client
      .send(command)
      .then((data) => parse(data))
      .catch((err) => err);

    this.cache.set('accountPlatforms', promise);
    return (await this.cache.get('accountPlatforms')) || []

然后我们会不一致地从承诺中得到像这样返回的结果。

{
    "$metadata": {
        "attempts": 1,
        "httpStatusCode": 200,
        "requestId": "redacted",
        "totalRetryDelay": 0
    },
    "ColumnInfo": [
        {
            "Name": "platform",
            "Type": [
                null
            ]
        },
        {
            "Name": "success",
            "Type": [
                null
            ]
        },
        {
            "Name": "failure",
            "Type": [
                null
            ]
        },
        {
            "Name": "total",
            "Type": [
                null
            ]
        }
    ],
    "NextToken": "redacted",
    "QueryId": "redacted",
    "QueryStatus": {
        "CumulativeBytesMetered": 10000000,
        "CumulativeBytesScanned": 108896,
        "ProgressPercentage": 67.63129689174706
    },
    "Rows": [
    ]
}

我没有找到一种方法可以从我们的服务内部通过 requestId 或 queryId 查找已完成的查询。

有人知道如何获取完整的查询吗?

I am using the node @aws-sdk/client-timestream-query 3.53.0 package. I am running into an issue where the result of ProgressPercentage is not 100 but the promise returned.


    const promise = this.client
      .send(command)
      .then((data) => parse(data))
      .catch((err) => err);

    this.cache.set('accountPlatforms', promise);
    return (await this.cache.get('accountPlatforms')) || []

Then inconsistently we will get results that return like this from the promise.

{
    "$metadata": {
        "attempts": 1,
        "httpStatusCode": 200,
        "requestId": "redacted",
        "totalRetryDelay": 0
    },
    "ColumnInfo": [
        {
            "Name": "platform",
            "Type": [
                null
            ]
        },
        {
            "Name": "success",
            "Type": [
                null
            ]
        },
        {
            "Name": "failure",
            "Type": [
                null
            ]
        },
        {
            "Name": "total",
            "Type": [
                null
            ]
        }
    ],
    "NextToken": "redacted",
    "QueryId": "redacted",
    "QueryStatus": {
        "CumulativeBytesMetered": 10000000,
        "CumulativeBytesScanned": 108896,
        "ProgressPercentage": 67.63129689174706
    },
    "Rows": [
    ]
}

I don't see a way to look up the completed query either by requestId or queryId from inside the our service.

Anyone know how to get the completed query?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温暖的光 2025-01-18 12:04:04

如果 ProgressPercentage<100,您需要使用您获得的第一个查询结果中的“NextToken”,并使用它来使用它进行新查询。
然后你就会得到结果。

我就是这样做的。

就像在 Python 中一样,我这样做:

if query['QueryStatus']['ProgressPercentage']<100:
        next_token = query['NextToken']
        query = timestream_query_client.query(QueryString=queryString, NextToken=next_token)

希望它在一段时间后也能有所帮助,或者谁接下来会遇到同样的问题。

You need to use the "NextToken" from the first query result you obtain and use it to make a new query using it, if the ProgressPercentage<100.
You will then have the result.

This is the way i do.

Like in Python i do:

if query['QueryStatus']['ProgressPercentage']<100:
        next_token = query['NextToken']
        query = timestream_query_client.query(QueryString=queryString, NextToken=next_token)

Hope it helps also after time or who is coming next having the same problem.

梦幻之岛 2025-01-18 12:04:04

进度百分比< 100表示​​查询尚未完成。如果查询运行时间超过定义的超时时间,则会从 Amazon Timestream 返回此值。每当你看到这个时,你应该预料到 rows[] 是空的,但你得到了一个 NextToken。

您可以按照此处所述使用下一个令牌进行轮询:

https://docs.aws.amazon.com/timestream/latest/developerguide/code-samples.run-query.html

a progress percentage < 100 means that the query is not yet done. This is returned from Amazon Timestream in case the query runs longer than the defined timeout. Whenever you see this, you should expect that rows[] is empty but you get a NextToken.

You can poll with next token as described here:

https://docs.aws.amazon.com/timestream/latest/developerguide/code-samples.run-query.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文