You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by JoshRosen <gi...@git.apache.org> on 2015/10/20 03:08:52 UTC

[GitHub] spark pull request: [SPARK-9735][SQL]Respect the user specified sc...

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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org