fix(athena): report the result CSV object key as OutputLocation (#1895)

GetQueryExecution reported OutputLocation as a directory prefix
(<base>/<queryId>/) while the result was written to results.csv
inside it, so a client GET on the reported location failed with
NoSuchKey. Real Athena names result files <QueryID>.csv and saves
them directly to the result location for API queries.

Resolve the location to <base>/<queryId>.csv and write the CSV to
exactly that key. The reader lists by prefix, so it finds the new
form and still reads executions persisted with the old prefix form.

Closes #1752
This commit is contained in:
soreavis authored and GitHub committed 2026-07-29 21:46:29 -05:00
1 parent b60a58fab6
commit 418ec1bdae
2 files changed
+35 -3

No files matched your search

@@ -377,4 +377,35 @@ class AthenaIntegrationTest {
.body("TableMetadata.CreateTime", instanceOf(Number.class))
.body("TableMetadata.LastAccessTime", instanceOf(Number.class));
}
@Test
@Order(13)
void outputLocationIsTheResultCsvObjectKey() {
String id = given()
.header("X-Amz-Target", "AmazonAthena.StartQueryExecution")
.contentType(CONTENT_TYPE)
.body("""
{
"QueryString": "SELECT 1",
"ResultConfiguration": { "OutputLocation": "s3://athena-location-test/out/" }
}
""")
.when()
.post("/")
.then()
.statusCode(200)
.extract().path("QueryExecutionId");
// AWS reports the result CSV object itself, not a directory prefix
given()
.header("X-Amz-Target", "AmazonAthena.GetQueryExecution")
.contentType(CONTENT_TYPE)
.body("{ \"QueryExecutionId\": \"" + id + "\" }")
.when()
.post("/")
.then()
.statusCode(200)
.body("QueryExecution.ResultConfiguration.OutputLocation",
equalTo("s3://athena-location-test/out/" + id + ".csv"));
}
}