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
would like to see Add GetNamedQuery By QueryName #753
Comments
Thanks for the feature request. The Athena team maintains the underlying GetNamedQuery and ListNamedQueries APIs, so we would have to forward feature requests involving the API behavior to them.
As you suggested above, creating a new API may be the best solution due to the need to maintain backwards compatibility. To make sure that we correctly understand the ask here, can you verify that the following accomplishes what you're trying to do using Boto3: import boto3
client = boto3.client('athena')
response = client.list_named_queries()
query_ids = response['NamedQueryIds']
named_queries = [client.get_named_query(NamedQueryId=id)['NamedQuery'] for id in query_ids]
filtered_queries = [q for q in named_queries if q['Name'] == '<query name>']
for query in filtered_queries:
print(query) Or using a bash script: #!/bin/bash
# Set the query name to filter for
query_name="<query name>"
# List named queries
named_query_ids=$(aws athena list-named-queries --query "NamedQueryIds" --output text)
# Loop through the named query IDs
for query_id in $named_query_ids
do
# Get the named query details
named_query=$(aws athena get-named-query --named-query-id "$query_id")
# Extract the query name
query_name_from_response=$(echo "$named_query" | jq -r '.NamedQuery.Name')
# Check if the query name matches the filter
if [ "$query_name_from_response" == "$query_name" ]; then
echo "$named_query"
fi
done I think those workarounds meet your use case, but we can still forward the feature request to the Athena team for review. |
Yes, it can be accomplished with both the boto3 and shell scripts listed. (The AWS Athena console implementation was the same.) That is where I would like to write this if possible (I will show an example with boto3) import boto3
already_known_query_name = 'the query'
client = boto3.client('athena')
response = client.get_named_queries(name=already_known_query_name)
print(response[0]) # the query data |
Thanks for confirming, I'll transfer this to our cross-SDK repository (since service APIs like this are used across AWS SDKs) and I'll reach out to the Athena team for feedback on this feature request. (ref: P131190888) |
Describe the feature
hello.
It is an automatic translation and may result in strange English. Sorry.
I would like to be able to search an Athena NamedQuery by the Name of the Query.
The current implementation of GetNamedQuery() is only from the auto-generated query_id, and it is difficult to keep track of this id from the program.
ref: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/get-named-query.html
Also, ListNamedQueries() must be implemented to retrieve this ID programmatically, but the response from this API is only a list of IDs, and we do not know which ID is the desired query.
ref: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/list-named-queries.html
(For example, if the name of the query as well as the ID is recorded here, you can use the query option of the AWS CLI to filter the results.)
Use Case
Looking at the implementation of getting NamedQuery in AWS Athena Console from Chrome Dev tools, it executes all ListNamedQueries and then GetNamedQuery one by one, which becomes more inefficient as the number of NamedQueries increases.
Proposed Solution
I would like to see GetNamedQueryByName added or name added to the ListNamedQueries response.
Changing the response of ListNamedQueries would lose backward compatibility, so if anything we should add GetNamedQueryByName or another solution.
Other Information
No response
Acknowledgements
CLI version used
aws-cli/2.15.36 Python/3.11.9 Darwin/23.4.0 source/arm64 prompt/off
Environment details (OS name and version, etc.)
Mac OS Sonoma 14.4.1
The text was updated successfully, but these errors were encountered: