Skip to content

Commit d09d561

Browse files
chore: generate
1 parent 85ef35d commit d09d561

1 file changed

Lines changed: 26 additions & 31 deletions

File tree

packages/stats/core/src/athena.ts

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -113,37 +113,32 @@ const poll: (
113113
return yield* poll(client, queryExecutionId, attempt + 1)
114114
})
115115

116-
const results: (
117-
client: AwsAthenaClient,
118-
queryExecutionId: string,
119-
) => Effect.Effect<AthenaData[], AthenaQueryError> = Effect.fn("Athena.results")(function* (
120-
client: AwsAthenaClient,
121-
queryExecutionId: string,
122-
) {
123-
// Accumulate pages iteratively; recursive spreads copied every previously
124-
// fetched row per page and blew up memory on large result sets.
125-
const rows: AthenaData[] = []
126-
let nextToken: string | undefined
127-
while (true) {
128-
const result = yield* Effect.tryPromise({
129-
try: () =>
130-
client.send(
131-
new GetQueryResultsCommand({
132-
QueryExecutionId: queryExecutionId,
133-
NextToken: nextToken,
134-
MaxResults: ATHENA_PAGE_SIZE,
135-
}),
136-
),
137-
catch: (cause) =>
138-
new AthenaQueryError({ message: "Failed to read Athena stats results", queryExecutionId, cause }),
139-
})
140-
const columns = result.ResultSet?.ResultSetMetadata?.ColumnInfo?.map((item) => item.Name ?? "") ?? []
141-
// The first page starts with the header row.
142-
for (const row of (result.ResultSet?.Rows ?? []).slice(nextToken ? 0 : 1)) rows.push(rowData(columns, row))
143-
if (!result.NextToken) return rows
144-
nextToken = result.NextToken
145-
}
146-
})
116+
const results: (client: AwsAthenaClient, queryExecutionId: string) => Effect.Effect<AthenaData[], AthenaQueryError> =
117+
Effect.fn("Athena.results")(function* (client: AwsAthenaClient, queryExecutionId: string) {
118+
// Accumulate pages iteratively; recursive spreads copied every previously
119+
// fetched row per page and blew up memory on large result sets.
120+
const rows: AthenaData[] = []
121+
let nextToken: string | undefined
122+
while (true) {
123+
const result = yield* Effect.tryPromise({
124+
try: () =>
125+
client.send(
126+
new GetQueryResultsCommand({
127+
QueryExecutionId: queryExecutionId,
128+
NextToken: nextToken,
129+
MaxResults: ATHENA_PAGE_SIZE,
130+
}),
131+
),
132+
catch: (cause) =>
133+
new AthenaQueryError({ message: "Failed to read Athena stats results", queryExecutionId, cause }),
134+
})
135+
const columns = result.ResultSet?.ResultSetMetadata?.ColumnInfo?.map((item) => item.Name ?? "") ?? []
136+
// The first page starts with the header row.
137+
for (const row of (result.ResultSet?.Rows ?? []).slice(nextToken ? 0 : 1)) rows.push(rowData(columns, row))
138+
if (!result.NextToken) return rows
139+
nextToken = result.NextToken
140+
}
141+
})
147142

148143
function rowData(columns: string[], row: Row): AthenaData {
149144
return Object.fromEntries(

0 commit comments

Comments
 (0)