You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by HyukjinKwon <gi...@git.apache.org> on 2017/01/25 04:03:01 UTC

[GitHub] spark pull request #16680: [WIP][SPARK-16101][SQL] Refactoring CSV schema in...

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

    https://github.com/apache/spark/pull/16680#discussion_r97706016
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVInferSchema.scala ---
    @@ -39,22 +37,76 @@ private[csv] object CSVInferSchema {
        *     3. Replace any null types with string type
        */
       def infer(
    -      tokenRdd: RDD[Array[String]],
    -      header: Array[String],
    +      csv: Dataset[String],
    +      caseSensitive: Boolean,
           options: CSVOptions): StructType = {
    -    val startType: Array[DataType] = Array.fill[DataType](header.length)(NullType)
    -    val rootTypes: Array[DataType] =
    -      tokenRdd.aggregate(startType)(inferRowType(options), mergeRowTypes)
    -
    -    val structFields = header.zip(rootTypes).map { case (thisHeader, rootType) =>
    -      val dType = rootType match {
    -        case _: NullType => StringType
    -        case other => other
    +    val firstLine: String = CSVUtils.filterCommentAndEmpty(csv, options).first()
    --- End diff --
    
    Both `CSVUtils.filterCommentAndEmpty` usages here and below should exactly the same up to my knowledge but I let them as are just simply to keep the behaviour for now.


---
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