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
181 stars 70 forks source link

getQueryResultsFromS3 function should be able to support subfolders #4

Closed deliverymanager closed 5 years ago

deliverymanager commented 5 years ago

If I declare

const athenaExpressConfig = {
  aws,
  s3: "s3://bucket-name/sub-directory/",
  db: process.env.athena_database,
  getStats: true
};

then this functions fails. Consider replacing with the following:

function getQueryResultsFromS3(params) {
const bucket = params.config.s3Bucket.replace("s3://", "").split("/")[0];
    const s3Params = {
            Bucket: bucket,
            Key: params.s3Output.replace("s3://" + bucket + "/", "")
        }
ghdna commented 5 years ago

Just pushed 3.3.0 that supports sub folders. Good catch!