Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5662

Compliant text reader (CSV) opens, closes, reopens file with headers

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.10.0
    • Future
    • Storage - Text & CSV
    • None

    Description

      The "compliant" (CSV) reader can optional read headers from a file. To do so, the reader:

      • Opens the input stream
      • Reads headers
      • Closes the input stream
      • Opens the input stream
      • Reads data (skipping headers)
      • Closes the input stream

      While the above certainly works, it has an unnecessary close/open cycle. Many CSV readers simply read the header and use the same stream to read data. Drill should do so also.

      In fact, Drill has historically coded its own headers scanner. The first was badly broken, but DRILL-5498 improved the parsing (though not file handling.)

      Given that Drill's "compliant" text reader is based on the UniVocity library, and that library can parse headers, we should probably just reuse that existing code which has, very likely, evolved to handle the header usages seen in the wild.

      Text files allow "splits", so there are two cases here:

      • A small file (or the first split) in which the header is contiguous with the data. This is the case we should modify the code to support.
      • A large file where the reader reads the second or subsequent split. In this case, the header is not contiguous with the data. In this case, the current behavior of opening the file twice is perhaps the best solution (since the splits are probably on separate nodes.)

      Attachments

        Activity

          People

            paul-rogers Paul Rogers
            paul-rogers Paul Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: