aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

`aws dynamodb query` and `aws dynamodb scan` commands are missing docs for the `--limit` parameter

Open dead10ck opened this issue 1 year ago • 6 comments
trafficstars

Describe the bug

The dynamodb query and dynamodb scan subcommands both seem to respond to a --limit parameter by setting the Limit query parameter as expected; however, --limit is not documented at all in the help pages.

Expected Behavior

--limit should be documented

Current Behavior

It is not

Reproduction Steps

Run aws dynamodb query help

Possible Solution

No response

Additional Information/Context

No response

CLI version used

aws-cli/2.17.26 Python/3.11.9 Linux/6.5.0-45-generic exe/x86_64.ubuntu.22

Environment details (OS name and version, etc.)

Ubuntu 22.04

dead10ck avatar Aug 09 '24 15:08 dead10ck

Hey @dead10ck, thanks for reaching out. AWS CLI obscures service pagination parameters like --limit in favor of the CLI pagination parameters (--max-items being the analog to --limit). This is done so that pagination in the CLI is consistent between services. However, the service pagination parameters still work, as you mentioned. Please let me know if you have any follow-up questions.

RyanFitzSimmonsAK avatar Aug 14 '24 20:08 RyanFitzSimmonsAK

But pagination doesn't serve the same purpose as limiting the results of a scan or query. When you --limit a query to 1, you are only charged RCUs for that one row; when you use --max-items, you are charged RCUs for I think the full result set? You can verify by checking the consumed RCUs.

dead10ck avatar Aug 15 '24 02:08 dead10ck

You should be able to accomplish the same thing using a combination of --max-items and --page-size.

aws dynamodb scan --table-name testTable --limit 1

...
    "Count": 1,
    "ScannedCount": 1,
...

If using only --max-items, all items are scanned as you mentioned. aws dynamodb scan --table-name testTable --max-items 1

...
    "Count": 3,
    "ScannedCount": 3,
    "ConsumedCapacity": null,
    "NextToken": "eyJFeGNsdXNpdmVTdGFydEtleSI6IG51bGwsICJib3RvX3RydW5jYXRlX2Ftb3VudCI6IDF9"

Using both --max-items and page-size correctly restricts the number of scanned and returned items. aws dynamodb scan --table-name testTable --page-size 1 --max-items 1

...
    "Count": 1,
    "ScannedCount": 1,
    "ConsumedCapacity": null,
    "NextToken": "eyJFeGNsdXNpdmVTdGFydEtleSI6IHsiTmFtZSI6IHsiUyI6ICJDYW1teSJ9fX0="

RyanFitzSimmonsAK avatar Aug 28 '24 19:08 RyanFitzSimmonsAK

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

github-actions[bot] avatar Sep 07 '24 20:09 github-actions[bot]

Ah, you are right, thanks! Is that documented anywhere? That doesn't seem like an obvious way to use query limits with the CLI.

dead10ck avatar Sep 08 '24 02:09 dead10ck

It's explained a bit in the description for page-size.

The size of each page to get in the AWS service call. This does not affect the number of items returned in the command’s output. Setting a smaller page size results in more calls to the AWS service, retrieving fewer items in each call.

--page-size 1 means that it will scan one item at a time until it reaches --max-items total items (in this case also one).

RyanFitzSimmonsAK avatar Sep 11 '24 18:09 RyanFitzSimmonsAK

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

github-actions[bot] avatar Sep 21 '24 19:09 github-actions[bot]