-
Notifications
You must be signed in to change notification settings - Fork 722
feat(athena): add start_query_executions for parallel query execution #3190
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
Conversation
Introduce `wr.athena.start_query_executions` as a parallelized variant of `start_query_execution`. It allows submitting multiple queries in one call, with support for: - Sequential or threaded submission (`use_threads`) - Lazy or eager consumption of results (`as_iterator`) - Per-query `client_request_token` (string or list) - Optional workgroup checks (`check_workgroup`, `enforce_workgroup`) - Full Athena cache integration This improves performance when dispatching batches of queries by reducing workgroup lookups and enabling concurrent execution.
…nd parallel wait - Simplified client_request_token handling: - Removed manual padding/truncation. - Let Athena enforce length constraints. - Tokens generated as `<base_token>-<index>` or provided as list. - Improved wait logic: - Added optional wait handling directly inside _submit. - Queries can now be waited in parallel with submission (reduced overhead). - Configurable default threads: - Replaced hardcoded defaults with os.cpu_count(). - Added support for AWSWRANGLER_THREADS_DEFAULT env var override.
- Removed unused `reduce` import from Athena module. - Applied ruff formatting to `start_query_executions`. - Fixed static check issues to pass CI. - Added ruff check on Athena tests file.
kukushking
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thank you for opening this PR!
What is the reason to build this into the SDK? Is this a common use case to submit x queries in parallel? Feels like it is specific to your concrete application logic
|
Hi @kukushking, thanks for the review! I see that this pattern shows up in data workflows where many short Athena queries must run together. A few common examples:
API symmetry & ergonomics: Parallel submission and coordinated wait help improve performance while respecting quotas via a configurable concurrency. The implementation is opt-in, non-breaking, and uses the same guardrails already present for single-query flows. Why I contributed this: Happy to adjust naming, docs, or move it behind a helper/recipe if you prefer, but I believe the symmetry and the prevalence of these data workflows justify having this in the SDK. In the future, it would be great to support retrieving results in the same parallel manner. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thanks for the comment @ggiallo28 .
I agree running queries one by one slows down the process, however that does not explain why this should be handled in the SDK, and not your BI application logic. I am a bit cautious to add this to SDK as the same reasoning may be extended to any other call the library provides, adding overhead and negatively impacting maintainability.
|
Feature or Bugfix
Detail
Relates
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.