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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org