Skip to content

Commit

Permalink
Add snowflake test schema environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
pondzix committed Aug 3, 2023
1 parent ba51725 commit 86040f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.snowplowanalytics.snowplow.collectors.scalastream.e2e.storage.Snowfla
* - TEST_SNOWFLAKE_URL (format like: 'jdbc:snowflake://${accountName}.snowflakecomputing.com')
* - TEST_SNOWFLAKE_WAREHOUSE
* - TEST_SNOWFLAKE_DATABASE
* - TEST_SNOWFLAKE_SCHEMA
* - TEST_SNOWFLAKE_USERNAME
* - TEST_SNOWFLAKE_PASSWORD
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.snowplowanalytics.snowplow.collectors.scalastream.e2e.storage

import cats.effect.{ContextShift, IO}
import SnowflakeSupport._
import doobie.Transactor
import doobie.{Fragment, Transactor}
import doobie.implicits._
import doobie.util.fragment

Expand All @@ -27,13 +27,16 @@ trait SnowflakeSupport extends StorageTarget {
)
}

override def countEventsWithAppIdQuery(appId: String): fragment.Fragment =
sql"""select count(*) from atomic.events where app_id = $appId"""
override def countEventsWithAppIdQuery(appId: String): fragment.Fragment = {
val schema = System.getenv(snowflakeSchemaEnv)
sql"select count(*) from ${Fragment.const0(s"$schema.events")} where app_id = $appId"
}

override def storageEnvironmentVariables: List[String] = List(
snowflakeUrlEnv,
snowflakeWarehouseEnv,
snowflakeDatabaseEnv,
snowflakeSchemaEnv,
snowflakeUsernameEnv,
snowflakePasswordEnv
)
Expand All @@ -44,6 +47,7 @@ object SnowflakeSupport {
val snowflakeUrlEnv = "TEST_SNOWFLAKE_URL"
val snowflakeWarehouseEnv = "TEST_SNOWFLAKE_WAREHOUSE"
val snowflakeDatabaseEnv = "TEST_SNOWFLAKE_DATABASE"
val snowflakeSchemaEnv = "TEST_SNOWFLAKE_SCHEMA"
val snowflakeUsernameEnv = "TEST_SNOWFLAKE_USERNAME"
val snowflakePasswordEnv = "TEST_SNOWFLAKE_PASSWORD"
}

0 comments on commit 86040f9

Please sign in to comment.