Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore exception for trying to resize a column with text255 compresssion encoding #1370

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
- name: Install sbt
uses: sbt/setup-sbt@v1
- name: Check Scala formatting
if: ${{ always() }}
run: sbt scalafmtCheckAll scalafmtSbtCheck
Expand Down Expand Up @@ -53,6 +55,8 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
- name: Install sbt
uses: sbt/setup-sbt@v1
- name: Get the latest Databricks JDBC driver
run: |
curl https://databricks-bi-artifacts.s3.us-east-2.amazonaws.com/simbaspark-drivers/jdbc/2.6.40/DatabricksJDBC42-2.6.40.1070.zip --output DatabricksJDBC42.jar.zip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
package com.snowplowanalytics.snowplow.rdbloader.loading

import java.sql.SQLException
import java.time.Instant
import cats.{Monad, MonadThrow, Show}
import cats.implicits._
Expand Down Expand Up @@ -162,6 +163,9 @@ object Load {
val awsColumnResizeError: String =
raw"""\[Amazon\]\(500310\) Invalid operation: cannot alter column "[^\s]+" of relation "[^\s]+", target column size should be different;"""

val awsText255ResizeError: String =
raw"""\[Amazon\]\(500310\) Invalid operation: cannot alter column "[^\s]+" of relation "[^\s]+" with encode type "text255";"""

// It is important we return a _list_ of C[Unit] so that each migration step can be transacted indepdendently.
// Otherwise, Hikari will not let us catch/handle/ignore the exceptions we encounter along the way.
def getPreTransactions[C[_]: Logging: MonadThrow: DAO](
Expand All @@ -182,6 +186,13 @@ object Load {
// to use the same connection again.
case e if e.getMessage.matches(awsColumnResizeError) =>
().pure[C]

// Starting with Schema DDL 0.27.0, compression encoding of the columns for enum fields is changed
// to zstd from text255. zstd encoding allows to change the column size. However, encoding of the existing
// columns isn't change and their encoding is still text255. Therefore, it is possible to get exception
// while trying to resize those columns. This case is added to catch those exceptions and ignore them.
case e if e.getMessage.matches(awsText255ResizeError) =>
Logging[C].warning(s"Resizing the column with text255 encoding is ignored: ${e.getMessage}")
}
.onError { case _: Throwable => incrementAttempt }
}
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object Dependencies {

val spark = "3.3.1"
val eventsManifest = "0.4.0"
val schemaDdl = "0.25.0"
val schemaDdl = "0.27.0-M1"
val jacksonModule = "2.17.2" // Override incompatible version in spark runtime
val jacksonDatabind = "2.17.2"
val jacksonMapper = "1.9.14-atlassian-6" // Fix CVE
Expand Down
Loading