Skip to content

Commit 84efdf3

Browse files
committed
fix(athena): address PR review comments
- Fix variable shadowing: rename inner `data` to `rowData` in row mapper - Fix first-page maxResults off-by-one: request maxResults+1 to compensate for header row - Add missing runtime guard for queryString in create_named_query - Move athena registry entries to correct alphabetical position
1 parent 9f22b36 commit 84efdf3

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

apps/sim/app/api/tools/athena/get-query-results/route.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ export async function POST(request: NextRequest) {
3535
secretAccessKey: data.secretAccessKey,
3636
})
3737

38+
const isFirstPage = !data.nextToken
39+
const adjustedMaxResults =
40+
data.maxResults !== undefined && isFirstPage ? data.maxResults + 1 : data.maxResults
41+
3842
const command = new GetQueryResultsCommand({
3943
QueryExecutionId: data.queryExecutionId,
40-
...(data.maxResults !== undefined && { MaxResults: data.maxResults }),
44+
...(adjustedMaxResults !== undefined && { MaxResults: adjustedMaxResults }),
4145
...(data.nextToken && { NextToken: data.nextToken }),
4246
})
4347

@@ -53,9 +57,9 @@ export async function POST(request: NextRequest) {
5357
const dataRows = data.nextToken ? rawRows : rawRows.slice(1)
5458
const rows = dataRows.map((row) => {
5559
const record: Record<string, string> = {}
56-
const data = row.Data ?? []
60+
const rowData = row.Data ?? []
5761
for (let i = 0; i < columns.length; i++) {
58-
record[columns[i].name] = data[i]?.VarCharValue ?? ''
62+
record[columns[i].name] = rowData[i]?.VarCharValue ?? ''
5963
}
6064
return record
6165
})

apps/sim/blocks/blocks/athena.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ Return ONLY the SQL query — no explanations, no markdown code blocks.`,
297297
if (!rest.database) {
298298
throw new Error('Database is required')
299299
}
300+
if (!rest.queryString) {
301+
throw new Error('SQL query string is required')
302+
}
300303
return {
301304
awsRegion,
302305
awsAccessKeyId,

apps/sim/tools/registry.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,6 +2840,14 @@ export const tools: Record<string, ToolConfig> = {
28402840
ashby_remove_candidate_tag: ashbyRemoveCandidateTagTool,
28412841
ashby_search_candidates: ashbySearchCandidatesTool,
28422842
ashby_update_candidate: ashbyUpdateCandidateTool,
2843+
athena_start_query: athenaStartQueryTool,
2844+
athena_get_query_execution: athenaGetQueryExecutionTool,
2845+
athena_get_query_results: athenaGetQueryResultsTool,
2846+
athena_stop_query: athenaStopQueryTool,
2847+
athena_list_query_executions: athenaListQueryExecutionsTool,
2848+
athena_create_named_query: athenaCreateNamedQueryTool,
2849+
athena_get_named_query: athenaGetNamedQueryTool,
2850+
athena_list_named_queries: athenaListNamedQueriesTool,
28432851
brandfetch_get_brand: brandfetchGetBrandTool,
28442852
brandfetch_search: brandfetchSearchTool,
28452853
box_copy_file: boxCopyFileTool,
@@ -3434,14 +3442,6 @@ export const tools: Record<string, ToolConfig> = {
34343442
rds_delete: rdsDeleteTool,
34353443
rds_execute: rdsExecuteTool,
34363444
rds_introspect: rdsIntrospectTool,
3437-
athena_start_query: athenaStartQueryTool,
3438-
athena_get_query_execution: athenaGetQueryExecutionTool,
3439-
athena_get_query_results: athenaGetQueryResultsTool,
3440-
athena_stop_query: athenaStopQueryTool,
3441-
athena_list_query_executions: athenaListQueryExecutionsTool,
3442-
athena_create_named_query: athenaCreateNamedQueryTool,
3443-
athena_get_named_query: athenaGetNamedQueryTool,
3444-
athena_list_named_queries: athenaListNamedQueriesTool,
34453445
cloudformation_describe_stacks: cloudformationDescribeStacksTool,
34463446
cloudformation_list_stack_resources: cloudformationListStackResourcesTool,
34473447
cloudformation_detect_stack_drift: cloudformationDetectStackDriftTool,

0 commit comments

Comments
 (0)