Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8026#discussion_r42445776
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PartitioningUtils.scala
 ---
    @@ -236,15 +241,22 @@ private[sql] object PartitioningUtils {
       }
     
       /**
    -   * Converts a string to a [[Literal]] with automatic type inference.  
Currently only supports
    -   * [[IntegerType]], [[LongType]], [[DoubleType]], 
[[DecimalType.SYSTEM_DEFAULT]], and
    -   * [[StringType]].
    +   * Converts a string to a [[Literal]] with automatic type inference if 
no field type specified.
    +   * Auto inference only supports [[IntegerType]], [[LongType]], 
[[DoubleType]],
    +   * [[DecimalType.SYSTEM_DEFAULT]], and [[StringType]].
        */
       private[sql] def inferPartitionColumnValue(
    +      expectedDT: Option[DataType],
           raw: String,
           defaultPartitionName: String,
    -      typeInference: Boolean): Literal = {
    -    if (typeInference) {
    +      typeInference: Boolean): Literal = expectedDT match {
    +    case Some(dt) if raw == defaultPartitionName =>
    +      Literal.create(null, dt)
    +    case Some(dt) if dt == StringType =>
    +      Literal.create(unescapePathName(raw), StringType)
    +    case Some(dt) =>
    +      Literal.create(Cast(Literal.create(unescapePathName(raw), 
StringType), dt).eval(null), dt)
    --- End diff --
    
    Instead of `eval(null)`, I think this could simply be `eval()`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to