Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17068#discussion_r104329421
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVDataSource.scala
 ---
    @@ -190,28 +194,26 @@ object WholeFileCSVDataSource extends CSVDataSource {
           sparkSession: SparkSession,
           inputPaths: Seq[FileStatus],
           parsedOptions: CSVOptions): Option[StructType] = {
    -    val csv: RDD[PortableDataStream] = createBaseRdd(sparkSession, 
inputPaths, parsedOptions)
    -    val maybeFirstRow: Option[Array[String]] = csv.flatMap { lines =>
    +    val csv = createBaseRdd(sparkSession, inputPaths, parsedOptions)
    +    csv.flatMap { lines =>
           UnivocityParser.tokenizeStream(
             
CodecStreams.createInputStreamWithCloseResource(lines.getConfiguration, 
lines.getPath()),
    -        false,
    +        shouldDropHeader = false,
             new CsvParser(parsedOptions.asParserSettings))
    -    }.take(1).headOption
    -
    -    if (maybeFirstRow.isDefined) {
    -      val firstRow = maybeFirstRow.get
    -      val caseSensitive = 
sparkSession.sessionState.conf.caseSensitiveAnalysis
    -      val header = makeSafeHeader(firstRow, caseSensitive, parsedOptions)
    -      val tokenRDD = csv.flatMap { lines =>
    -        UnivocityParser.tokenizeStream(
    -          
CodecStreams.createInputStreamWithCloseResource(lines.getConfiguration, 
lines.getPath()),
    -          parsedOptions.headerFlag,
    -          new CsvParser(parsedOptions.asParserSettings))
    -      }
    -      Some(CSVInferSchema.infer(tokenRDD, header, parsedOptions))
    -    } else {
    -      // If the first row could not be read, just return the empty schema.
    -      Some(StructType(Nil))
    +    }.take(1).headOption match {
    --- End diff --
    
    same question


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

Reply via email to