A retailer exports product reviews to CSV with the columns review_id, product_id, rating, review_text, created_at and loads them into a staging table that types every column as text and ignores extra fields. Afterwards some rows hold text such as ' fast delivery' in created_at, others lack their last fields, and the table has 103,400 rows although the source holds 100,000 reviews. One raw line reads 9001,P-17,5,Great fit, fast delivery,2026-05-02. What is the most likely cause and fix?
Show the answer and explanation
Correct answer: B, Review texts hold unquoted commas and line breaks: commas shift later fields and newlines split records into extra rows; export with proper CSV quoting and reject rows with the wrong field count.
Explanation Data Quality
CSV is only safe when every field that contains the delimiter, a quote or a line break is quoted (RFC 4180): wrap the field in double quotes and double any inner quote. Free text such as reviews, addresses or chat messages breaks naive exports in two ways:
- Embedded delimiter:
Great fit, fast deliverybecomes two fields, sofast deliverylands increated_atand the real date becomes an extra field, which this loader silently drops. - Embedded newline: a review written over two lines is split into two records, one missing its trailing fields and one with text in its leading fields. That is where the extra 3,400 rows come from.
Correctly quoted, the line reads 9001,P-17,5,"Great fit, fast delivery",2026-05-02.
Fixes:
- Export with proper quoting, or use a format with explicit structure (Parquet, Avro, JSON Lines) for free text.
- Make the load strict: reject or quarantine rows whose field count differs from the header instead of ignoring extra fields.
- Reconcile row counts with the source system and check that typed columns parse (dates in
created_at, integers 1–5 inrating).
Why the alternatives fail: an encoding error garbles characters (for example 'ü' instead of 'ü') but does not move column boundaries. Duplicates would repeat complete, well-formed records rather than shift fields. A typed schema makes the misaligned rows fail to load, but it cannot move values back into the right columns.
Interview tip: treat "rows loaded = rows in source" and "every row has N fields" as non-negotiable pipeline checks; lenient loaders hide exactly this class of error.