@adobe/spacecat-shared-athena-client 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +29 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-athena-client-v1.0.4](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-athena-client-v1.0.3...@adobe/spacecat-shared-athena-client-v1.0.4) (2025-07-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add pagination for athena ([#848](https://github.com/adobe/spacecat-shared/issues/848)) ([2007cfa](https://github.com/adobe/spacecat-shared/commit/2007cfad79f1921ad015c9c0301cf790f9b9405d))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-athena-client-v1.0.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-athena-client-v1.0.2...@adobe/spacecat-shared-athena-client-v1.0.3) (2025-07-12)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
AthenaClient,
|
|
15
15
|
StartQueryExecutionCommand,
|
|
16
16
|
GetQueryExecutionCommand,
|
|
17
|
-
GetQueryResultsCommand,
|
|
18
17
|
QueryExecutionState,
|
|
18
|
+
paginateGetQueryResults,
|
|
19
19
|
} from '@aws-sdk/client-athena';
|
|
20
20
|
import { instrumentAWSClient, hasText } from '@adobe/spacecat-shared-utils';
|
|
21
21
|
|
|
@@ -220,29 +220,38 @@ export class AWSAthenaClient {
|
|
|
220
220
|
* @returns {Promise<Array>} – Parsed query results
|
|
221
221
|
*/
|
|
222
222
|
async query(sql, database, description = 'Athena query', opts = {}) {
|
|
223
|
-
const
|
|
224
|
-
backoffMs = this.backoffMs,
|
|
225
|
-
maxRetries = this.maxRetries,
|
|
226
|
-
pollIntervalMs = this.pollIntervalMs,
|
|
227
|
-
maxPollAttempts = this.maxPollAttempts,
|
|
228
|
-
} = opts;
|
|
223
|
+
const queryExecutionId = await this.execute(sql, database, description, opts);
|
|
229
224
|
|
|
230
|
-
this.log.
|
|
225
|
+
this.log.debug(`[Athena Client] Fetching paginated results for QueryExecutionId=${queryExecutionId}`);
|
|
231
226
|
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
description,
|
|
236
|
-
backoffMs,
|
|
237
|
-
maxRetries,
|
|
238
|
-
);
|
|
227
|
+
const paginationConfig = {
|
|
228
|
+
client: this.client,
|
|
229
|
+
};
|
|
239
230
|
|
|
240
|
-
|
|
231
|
+
const input = {
|
|
232
|
+
QueryExecutionId: queryExecutionId,
|
|
233
|
+
};
|
|
241
234
|
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
235
|
+
const paginator = paginateGetQueryResults(paginationConfig, input);
|
|
236
|
+
|
|
237
|
+
const allResults = [];
|
|
238
|
+
let pageCount = 0;
|
|
239
|
+
let totalRows = 0;
|
|
240
|
+
|
|
241
|
+
/* c8 ignore start */
|
|
242
|
+
for await (const page of paginator) {
|
|
243
|
+
pageCount += 1;
|
|
244
|
+
const pageRows = page.ResultSet?.Rows?.length || 0;
|
|
245
|
+
totalRows += pageRows;
|
|
246
|
+
|
|
247
|
+
this.log.debug(`[Athena Client] Processing page ${pageCount} with ${pageRows} rows`);
|
|
248
|
+
|
|
249
|
+
const pageResults = AWSAthenaClient.#parseAthenaResults(page);
|
|
250
|
+
allResults.push(...pageResults);
|
|
251
|
+
}
|
|
252
|
+
/* c8 ignore stop */
|
|
245
253
|
|
|
246
|
-
|
|
254
|
+
this.log.info(`[Athena Client] Fetched ${totalRows} total rows across ${pageCount} pages`);
|
|
255
|
+
return allResults;
|
|
247
256
|
}
|
|
248
257
|
}
|