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

    https://github.com/apache/spark/pull/17068#discussion_r104357269
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVDataSource.scala
 ---
    @@ -190,28 +194,28 @@ 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 --
    
    https://github.com/apache/spark/pull/17068#discussion_r104356866 did not 
show up when I write my comment. I am fine as is. I am not supposed to decide 
this.


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