Skip to content

Commit

Permalink
Spark: Avoid attempt to parsing partition path into different types i…
Browse files Browse the repository at this point in the history
…f type inference is disabled
  • Loading branch information
amogh-jahagirdar committed Jul 17, 2024
1 parent 573a57f commit 327fd9f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@ private[delta] object PartitionUtils {
timeZone: TimeZone,
dateFormatter: DateFormatter,
timestampFormatter: TimestampFormatter): Literal = {
val decimalTry = Try {

def decimalTry = Try {
// `BigDecimal` conversion can fail when the `field` is not a form of number.
val bigDecimal = new JBigDecimal(raw)
// It reduces the cases for decimals by disallowing values having scale (eg. `1.1`).
Expand All @@ -539,7 +540,7 @@ private[delta] object PartitionUtils {
Literal(bigDecimal)
}

val dateTry = Try {
def dateTry = Try {
// try and parse the date, if no exception occurs this is a candidate to be resolved as
// DateType
dateFormatter.parse(raw)
Expand All @@ -555,7 +556,7 @@ private[delta] object PartitionUtils {
Literal.create(dateValue, DateType)
}

val timestampTry = Try {
def timestampTry = Try {
val unescapedRaw = unescapePathName(raw)
// try and parse the date, if no exception occurs this is a candidate to be resolved as
// TimestampType
Expand Down

0 comments on commit 327fd9f

Please sign in to comment.