Skip to content

[Bug] CSV reader skips a data row in every split after the first when csv.include-header is enabled #9063

Description

@thswlsqls

Search before asking

  • I searched in the issues and found nothing similar.

Paimon version
master @ a5e87eb (2.1-SNAPSHOT)

Compute Engine
Engine-agnostic (format table read path)

Minimal reproduce step

  1. Create a CSV format table with 'csv.include-header' = 'true'.
  2. Write one uncompressed CSV file larger than source.split.target-size (default 128MB).
  3. SELECT COUNT(*).

What doesn't meet your expectations?
Expected: the count equals the number of data rows. Actual: it is short by (number of splits - 1).

SplitEnumerator.preferToSplitFile() splits such a file into (offset, length) segments, each read by a CsvFileReader. CsvFileReader#setupReading (line 62-69) calls readLine() on every split, ignoring offset. The header only exists at byte 0, so where offset > 0 the discarded line is that split's first data row.

Anything else?
The record straddling a boundary is already dropped by StandardLineReader#skipFirstLine and read in full by the previous split, so this extra readLine() is pure over-discard. A header plus 20 data rows, read as two segments, returns 19 rows.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions