import { SnowflakeConnectionParams } from "../../types/integrations/snowflake" ; import { decryptDataSourceParams } from "../services/datasource" ; import { runSnowflakeQuery } from "../services/snowflake" ; import SqlIntegration from "./SqlIntegration" ; export default class Snowflake extends SqlIntegration { params : SnowflakeConnectionParams ; setParams ( encryptedParams ) { this . params = decryptDataSourceParams < SnowflakeConnectionParams > ( encryptedParams ) ; } getSensitiveParamKeys ( ) { return [ "password" ] ; } runQuery ( sql ) { return runSnowflakeQuery ( this . params , sql ) ; } percentile ( col , percentile ) { return `APPROX_PERCENTILE(${ col }, ${ percentile })` ; } regexMatch ( col , regex ) { if ( regex . substr ( - 1 ) === "$" ) { regex = regex . substr ( 0 , regex . length - 1 ) ; } else { regex += ".*" ; } if ( regex . substr ( 0 , 1 ) === "^" ) { regex = regex . substr ( 1 ) ; } else { regex = ".*" + regex ; } return `rlike(${ col }, '${ regex }')` ; } formatDate ( col ) { return `TO_VARCHAR(${ col }, 'YYYY-MM-DD')` ; } castToString ( col ) { return `TO_VARCHAR(${ col })` ; } }