import { decryptDataSourceParams } from "../services/datasource" ; import { runAthenaQuery } from "../services/athena" ; import SqlIntegration from "./SqlIntegration" ; import { AthenaConnectionParams } from "../../types/integrations/athena" ; export default class Athena extends SqlIntegration { params : AthenaConnectionParams ; setParams ( encryptedParams ) { this . params = decryptDataSourceParams < AthenaConnectionParams > ( encryptedParams ) ; } getSensitiveParamKeys ( ) { return [ "accessKeyId" , "secretAccessKey" ] ; } toTimestamp ( date ) { return `from_iso8601_timestamp('${ date . toISOString ( ) }')` ; } runQuery ( sql ) { return runAthenaQuery ( this . params , sql ) ; } addHours ( col , hours ) { return `${ col } + INTERVAL '${ hours }' hour` ; } subtractHalfHour ( col ) { return `${ col } - INTERVAL '30' minute` ; } regexMatch ( col , regex ) { return `regexp_like(${ col }, '${ regex }')` ; } percentile ( col , percentile ) { return `approx_percentile(${ col }, ${ percentile })` ; } formatDate ( col ) { return `substr(to_iso8601(${ col }),0,10)` ; } }