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

    https://github.com/apache/spark/pull/21909#discussion_r207005019
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FailureSafeParser.scala
 ---
    @@ -56,9 +57,14 @@ class FailureSafeParser[IN](
         }
       }
     
    +  private val skipParsing = optimizeEmptySchema && schema.isEmpty
       def parse(input: IN): Iterator[InternalRow] = {
         try {
    -      rawParser.apply(input).toIterator.map(row => toResultRow(Some(row), 
() => null))
    +     if (skipParsing) {
    +       Iterator.single(InternalRow.empty)
    +     } else {
    +       rawParser.apply(input).toIterator.map(row => toResultRow(Some(row), 
() => null))
    --- End diff --
    
    > ... when the files having broken records?
    
    Syntactically broken or semantically (wrong types for example)?
    
    > Any behavior change after this PR?
    
    We have many tests in `CSVSuite` and `JSONSuite` for broken records. I have 
found behavior change in only one case: 
https://github.com/apache/spark/pull/21909/files#diff-fde14032b0e6ef8086461edf79a27c5dL2227
 . This is due to `Jackson` parser touches a few first bytes in the input 
stream even if it is not called. `Jackson` checks encoding eagerly. 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to