Skip to content

Commit

Permalink
Quote column names in Redshift load statements
Browse files Browse the repository at this point in the history
  • Loading branch information
istreeter committed Dec 13, 2023
1 parent dbabd2d commit ac8d459
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ package com.snowplowanalytics.snowplow.rdbloader.db

object Columns {

final case class ColumnName(value: String) extends AnyVal
final case class ColumnName(value: String) extends AnyVal {
def quoted: String = s""""$value""""
}

type EventTableColumns = List[ColumnName]

final case class ColumnsToCopy(names: List[ColumnName]) extends AnyVal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ object Redshift {
val frRegion = Fragment.const0(region.name)
val frMaxError = Fragment.const0(maxError.toString)
val frCompression = getCompressionFormat(compression)
val frColumns = Fragment.const0(columnsToCopy.names.map(_.value).mkString(","))
val frColumns = Fragment.const0(columnsToCopy.names.map(_.quoted).mkString(","))

sql"""COPY $frTableName ($frColumns) FROM '$frPath'
| CREDENTIALS '$frCredentials'
Expand Down

0 comments on commit ac8d459

Please sign in to comment.