-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing output from JSON to text changes the query behaviour #7504
Comments
Hi @acdha, thanks for raising this issue. I wasn't able to reproduce this behavior using your provided code snippet; could you provide the debug logs by adding |
@RyanFitzSimmonsAK Does your system have both RDS and AWS Backup snapshots? I suspect those are grouped differently in the underlying API response and the CLI is papering over the differences in the transform code because I only see this on Aurora clusters which have both of those enabled. |
Yes, I tried to reproduce it on an Aurora cluster with both types of snapshots, and was not able to reproduce this behavior. If you can provide debug logs, it will help me root source this issue. Please don't forget to redact any sensitive info. Thanks! |
Here's a redacted log of the two commands back to back: |
Hi @acdha. We were still unable to reproduce this behavior or figure it out from the logs. Can you explain how you have your client side pagination configured? Also, does this behavior occur if you do |
I have similar problem for aws s3api list-objects-v2 \
--bucket "my-bucket" \
--prefix "development" \
--query 'reverse(sort_by(Contents[?contains(Key, `template_config`)], &LastModified))[:1]' \
--output=text
# Output
"f4edd198b40bbdd55fe02ab819132ee4" development-b7781/template_config.json 2023-02-09T14:30:32+00:00 196 STANDARD
"c66e58a1e42da7f06794971663f36305" development-e7755/template_config.json 2023-01-31T14:01:14+00:00 196 STANDARD aws s3api list-objects-v2 \
--bucket "my-bucket" \
--prefix "development" \
--query 'reverse(sort_by(Contents[?contains(Key, `template_config`)], &LastModified))[:1]' \
--output=json
# Output
[
{
"Key": "development-b7781/template_config.json",
"LastModified": "2023-02-09T14:30:32+00:00",
"ETag": "\"f4edd198b40bbdd55fe02ab819132ee4\"",
"Size": 196,
"StorageClass": "STANDARD"
}
] |
I added aws s3api list-objects-v2 \
--bucket "my-bucket" \
--prefix "development" \
--query 'reverse(sort_by(Contents[?contains(Key, `template_config`)], &LastModified))[:1]' \
--output=text \
--no-paginate
# Output
"f4edd198b40bbdd55fe02ab819132ee4" development-b7781/template_config.json 2023-02-09T14:30:32+00:00 196 STANDARD |
Seeing this issue as well. In my case: aws stepfunctions list-executions \
--state-machine-arn arn:aws:states:us-east-1:XXXXXXXXXXXXX:stateMachine:my-step-function \
--query 'executions[0].executionArn' \
--output text
# Output
arn:aws:states:us-east-1:XXXXXXXXXXXXX:execution:my-step-function:EXAMPLE1
arn:aws:states:us-east-1:XXXXXXXXXXXXX:execution:my-step-function:EXAMPLE2 aws stepfunctions list-executions \
--state-machine-arn arn:aws:states:us-east-1:XXXXXXXXXXXXX:stateMachine:my-step-function \
--query 'executions[0].executionArn' \
--output json
# Output
arn:aws:states:us-east-1:XXXXXXXXXXXXX:execution:my-step-function:EXAMPLE1 Running with debug shows pagination happening (this only showed up after our 100th step function execution). It looks like the JMES query is being run on each response rather than at the end for the combined results when the |
Here's another example:
and
give different results. Incidentally, json, table, and yaml output are all in the correct order. Only text output is changed. reidg44's comment is spot on. The reason this test example surfaces the issue is that the server-side filters are complex and slow-ish. aws-cli/2.11.5 Python/3.11.2 Darwin/22.3.0 source/x86_64 prompt/off |
Hey, thanks everyone for providing more details and examples. This behavior is technically expected; @reidg44 is correct that this behavior occurs because the text is processed one page at a time, and each page returns the result of the query. This similar issue has a more detailed explanation. To avoid this behavior, you can either turn off pagination, or set a higher page size using |
@RyanFitzSimmonsAK @aBurmeseDev that explanation makes sense but I think there's still at least one thing which could be improved to avoid continued reports of this as a bug. The documentation for
Nothing about that says that one of the modes silently changes from buffered to streaming processing — the existence of the special case The path of least resistance here would be to update the |
Nothing about that says that one of the modes silently changes from buffered to streaming processing — the existence of the special case yaml-stream option implies the opposite — and streaming would also be desirable for JSON output on large queries (e.g. I use a plenty of other tools which emit line-oriented JSON to improve parallelism). |
The warning clarifying this behavior on the query page of the user guide has been added to the output page as well. Closing this issue. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
I have a query which returns the correct result using JSON output:
If I modify that command to add
--output=text
, it returns two results with the first one being out of order:Expected Behavior
Changing the output format should not change the query behaviour
Current Behavior
Changing the format from JSON to text causes some kind of structural change which is not visible in the source JSON (i.e. these are returned as a single list, not two lists).
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CLI version used
aws-cli/2.9.4 Python/3.11.0 Darwin/22.1.0 source/arm64 prompt/off
Environment details (OS name and version, etc.)
ProductName: macOS ProductVersion: 13.0.1 BuildVersion: 22A400
The text was updated successfully, but these errors were encountered: