Skip to content

Commit

Permalink
#547 Fix some partition scheme flag combinations resulting in 'match …
Browse files Browse the repository at this point in the history
…error'.
  • Loading branch information
yruslan committed Feb 19, 2025
1 parent a1a1bfb commit 06b6046
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ object PartitionSchemeParser {
val partitionMonthColumn = ConfigUtils.getOptionString(conf, PARTITION_MONTH_COLUMN_KEY).getOrElse(s"${infoDateColumn}_month")

(partitionByOpt, partitionPeriodOpt) match {
case (Some(true), None) => Some(PartitionScheme.PartitionByDay)
case (Some(false), _) => Some(PartitionScheme.NotPartitioned)
case (_, Some(PARTITION_PERIOD_DAY)) => Some(PartitionScheme.PartitionByDay)
case (_, Some(PARTITION_PERIOD_MONTH)) => Some(PartitionScheme.PartitionByMonth(partitionMonthColumn, partitionYearColumn))
Expand All @@ -46,7 +47,7 @@ object PartitionSchemeParser {
case (_, Some(period)) if !Seq(PARTITION_PERIOD_DAY, PARTITION_PERIOD_MONTH, PARTITION_PERIOD_YEAR).contains(period) =>
throw new IllegalArgumentException(s"Invalid value '$period' of '$PARTITION_PERIOD_KEY'. " +
s"Valid values are: $PARTITION_PERIOD_DAY, $PARTITION_PERIOD_MONTH, $PARTITION_PERIOD_YEAR_MONTH, $PARTITION_PERIOD_YEAR.")
case (None, None) => None
case _ => None
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class PartitionSchemeParserSuite extends AnyWordSpec {
assert(partitionSchemeOpt.isEmpty)
}

"return None for partition by day by default" in {
val conf = ConfigFactory.parseString("partition.by = true")
val partitionSchemeOpt = PartitionSchemeParser.fromConfig(conf, "info_date")

assert(partitionSchemeOpt.contains(PartitionScheme.PartitionByDay))
}

"return non-partitioned when specified" in {
val conf = ConfigFactory.parseString("partition.by = false")

Expand Down

0 comments on commit 06b6046

Please sign in to comment.