ghdna / athena-express

Athena-Express can simplify executing SQL queries in Amazon Athena AND fetching cleaned-up JSON results in the same synchronous or asynchronous request - well suited for web applications.
https://www.npmjs.com/package/athena-express
MIT License
179 stars 70 forks source link

Empty response when using pagination #69

Open camilinha opened 2 years ago

camilinha commented 2 years ago

Hi, I ran into an unexpected situation using pagination parameter.

The queries where I use pagination parameter sometimes return with an empty response. But if I run the same query on AWS console, there are results. The S3 file also has the correct response, but the library says otherwise.

If I take out the pagination parameter this problem never happens. But the case is that I have a query with many results, so I need to use the pagination.

Anyone has the same problem? Is there a solution for this?

Thanks!

ledoux7 commented 2 years ago

I was experiencing it too. What I think is happening is that the previous query/pagination is cached somehow between runs so when you have run through all the results you get empty results every query afterwards.

I'm running it in a lambda and a workaround that I found that fixed it was moving the initialization to inside the exports.handler like this

"use strict";

const AthenaExpress = require("athena-express");
const AWS = require("aws-sdk");

exports.handler = async (event) => {
    const athenaExpressConfig = {
        aws: AWS,
    };
    const athenaExpress = new AthenaExpress(athenaExpressConfig);
...
ghdna commented 2 years ago

Pushed a new version on NPM. Give this one a try please.