Forked from charlypoly/execute-aws-athena-query.js
Created
December 31, 2018 18:35
-
-
Save jewelsjacobs/ff6fbe4f30e8619572c86be97d92c387 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = (event, context, callback) => { | |
var AWS = require('aws-sdk'); | |
AWS.config.update({region: 'eu-west-1'}); // configure region | |
const athena = new AWS.Athena(); | |
athena.getNamedQuery({ NamedQueryId: '<your-query-id>' }, function(err, data) { | |
console.log('getNamedQuery', err, data); | |
if (!err) { | |
var params = { | |
QueryString: data.NamedQuery.QueryString, | |
ResultConfiguration: { | |
OutputLocation: 's3://<your-bucket-name>/<folder>', | |
}, | |
QueryExecutionContext: { | |
Database: 'segment' | |
} | |
}; | |
athena.startQueryExecution(params, function(err, data) { | |
console.log('startQueryExecution', err, data); | |
if (err) { | |
callback(err); | |
} else { | |
callback(null, 'query started'); | |
} | |
}); | |
} else { | |
callback(err); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment