davsclaus opened a new pull request, #28891:
URL: https://github.com/apache/camel/pull/28891

   Fixes [CAMEL-26100](https://issues.apache.org/jira/browse/CAMEL-26100).
   
   ### 1. A second startQueryExecution takes the result file of the first as 
its output location
   
   **What was wrong:** startQueryExecution reads the output location from the 
`CamelAwsAthenaOutputLocation` header before the `outputLocation` option. 
getQueryExecution, getQueryResults with `S3Pointer`, and startQueryExecution 
with `waitTimeout` set that same header to the result file of their query 
(`s3://bucket/path/<id>.csv`). So a second startQueryExecution in the route put 
its results under the result file of the first. `CamelAwsAthenaNextToken` was 
shared the same way: the token of listQueryExecutions was sent by a later 
getQueryResults (and the other way around), and the token of one query was sent 
for another query.
   
   **What changed:** the producer keeps the values it sets as results in 
exchange properties. When the input header still holds that value, it is not 
used:
   - `CamelAwsAthenaOutputLocation`: a later startQueryExecution falls back to 
the `outputLocation` option.
   - `CamelAwsAthenaNextToken`: used only by the operation that returned it 
(listQueryExecutions, or getQueryResults for the same query id). Manual paging 
as documented (getQueryResults then getQueryResults for the same query; 
listQueryExecutions then listQueryExecutions) works as before.
   
   A header that the route sets itself (a different value) is always used, so 
overriding by header as documented still works. I chose this over removing the 
result headers (as was done for `CamelAwsDdbTableName` in aws2-ddb) because the 
docs present `CamelAwsAthenaOutputLocation` and `CamelAwsAthenaNextToken` as 
results that routes read.
   
   ### 2. NullPointerException without a result configuration
   
   **What was wrong:** the output location was read as 
`queryExecution().resultConfiguration().outputLocation()`. A query execution 
without a `ResultConfiguration` (managed query results) failed with a 
`NullPointerException` in getQueryExecution, getQueryResults with `S3Pointer`, 
and startQueryExecution with `waitTimeout`.
   
   **What changed:** the header (and the `S3Pointer` body) is null in that case.
   
   ### 3. getQueryResults with S3Pointer does not check that the query has 
succeeded
   
   **Not changed in code**, only documented. The location is known as soon as 
the query starts, and a route may use `S3Pointer` to learn where the results 
will land; the `CamelAwsAthenaQueryExecutionState` header is already set. 
Failing on a non-succeeded query would break that. The docs now say the file is 
complete only when the state is `SUCCEEDED`.
   
   ### Tests
   
   New `Athena2ProducerResultHeadersTest` (10 tests, a recording subclass of 
the existing `AmazonAthenaClientMock`). 7 fail without the fix (start after 
start/getQueryExecution/S3Pointer, the three next-token cases, and the NPE 
case); 3 are controls that pass before and after (a route-set header after an 
operation is used, and paging of getQueryResults and listQueryExecutions with 
their own token). Full module suite: 71 tests, 0 failures; `-Psourcecheck` 
clean.
   
   ### Docs
   
   - Component doc: a paragraph on result headers under "Overriding query 
parameters with message headers", and the `S3Pointer` note. Catalog copy 
updated.
   - Upgrade guide 4.24: new section "camel-aws2-athena - result headers are 
not taken as the input of a later operation".
   - No header constants or options changed, so no DSL regeneration.
   
   ### Not changed
   
   - The producer still requires an output location for startQueryExecution, 
even for a workgroup with managed query results or an enforced output location. 
That is separate from this issue.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] CAMEL-26100: camel-aws2-... davsclaus (via GitHub) via commits

Reply via email to