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

Redshift: use zstd compression encoding instead text255 with the columns for enum fields #215

Merged
merged 1 commit into from
Dec 19, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ case class ShredModelEntry(
.flatMap(_.apply(subSchema))
.getOrElse(ShredModelEntry.ColumnType.RedshiftVarchar(ShredModelEntry.VARCHAR_SIZE))

lazy val compressionEncoding: ShredModelEntry.CompressionEncoding = (subSchema.`enum`, columnType) match {
case (Some(_), ShredModelEntry.ColumnType.RedshiftVarchar(size)) if size <= 255 =>
ShredModelEntry.CompressionEncoding.Text255Encoding
case (_, ShredModelEntry.ColumnType.RedshiftBoolean) => ShredModelEntry.CompressionEncoding.RunLengthEncoding
case (_, ShredModelEntry.ColumnType.RedshiftDouble) => ShredModelEntry.CompressionEncoding.RawEncoding
lazy val compressionEncoding: ShredModelEntry.CompressionEncoding = columnType match {
case ShredModelEntry.ColumnType.RedshiftBoolean => ShredModelEntry.CompressionEncoding.RunLengthEncoding
case ShredModelEntry.ColumnType.RedshiftDouble => ShredModelEntry.CompressionEncoding.RawEncoding
case _ => ShredModelEntry.CompressionEncoding.ZstdEncoding
}

Expand Down Expand Up @@ -169,7 +167,6 @@ object ShredModelEntry {

implicit val compressionEncodingShow: Show[CompressionEncoding] = Show.show {
case RawEncoding => s"ENCODE RAW"
case Text255Encoding => s"ENCODE TEXT255"
case ZstdEncoding => s"ENCODE ZSTD"
case RunLengthEncoding => "ENCODE RUNLENGTH"
}
Expand All @@ -178,8 +175,6 @@ object ShredModelEntry {

case object RunLengthEncoding extends CompressionEncoding

case object Text255Encoding extends CompressionEncoding

case object ZstdEncoding extends CompressionEncoding
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class ShredModelEntrySpec extends Specification {
}

"suggest compression" should {
"suggest Text255Encoding for enums less then 255 in length" in {
"suggest zstd for enums less then 255 in length" in {
val props = json"""{"type": "string", "enum": ["one", "two"], "maxLength": 42}""".schema
ShredModelEntry(dummyPtr, props).compressionEncoding must beEqualTo(Text255Encoding)
ShredModelEntry(dummyPtr, props).compressionEncoding must beEqualTo(ZstdEncoding)
}

"suggest RunLengthEncoding for booleans" in {
Expand Down
Loading