Repository navigation
refactor(cubestore): append CSV import values directly into Arrow builders - #11064
Conversation
…ll semantics
Pin current parse behavior before refactoring the row-oriented import path:
- null markers ("", \N, \\N) across String/Int/Decimal/Timestamp, plus quoted-empty
- typed parse-failure semantics (Int/Int96 -> Null, Float/Decimal/Timestamp -> Err)
- Int96/Float/Decimal/Decimal96/Bytes/Timestamp value mapping with hardcoded expectations
- HLL re-serialization for Postgres and Snowflake flavors
- decimal precision-overflow error path
- quoting with delimiter/newline/escape, including across read-buffer boundaries
Remove the per-row Row/Vec<TableValue> intermediate from the file-import path: do_import now drives the line stream through CsvImportParser and appends straight into the column builders. String values go directly into the StringBuilder, dropping the TableValue::String allocation. Line splitting, header mapping and null-marker handling are shared between the builder path and the Row-producing path (still used by HTTP inline tables) via CsvImportParser, so the two cannot diverge. A header that maps two fields to the same column is now rejected instead of silently doing last-write-wins, which keeps the one-append-per-column builder invariant. Differential tests assert the builder path matches the Row path through identical Arrow reconstruction.
|
Claude finished @waralexrom's task in 2m 15s —— View job Code ReviewOverall: nice refactor. Sharing the Review checklist (click to expand)
Findings1. Behavior change worth surfacing — duplicate header columns now hard-error (low)
2. builder
.as_any_mut()
.downcast_mut::<datafusion::arrow::array::StringBuilder>()
.unwrap()
.append_value(value);This is reachable only if 3. Partial builder advance on visitor error in In the builder path, if 4. In 5.
Things done well
|
…gBuilder downcast A builder type mismatch with the column type is an internal invariant violation, not user input, so surface it as CubeError::internal.
|
Claude finished @waralexrom's task in 33s —— View job Re-review of new commitLooked at This directly addresses prior finding #2: the Nothing else to flag on this commit. Prior findings #1 (duplicate-header hard-error is a user-visible behavior change worth a changelog note), #3 (field-level partial-advance comment), #4 (double error wrapping on Row path), and #5 (HashSet vs Vec) all remain low/informational — not blocking. LGTM. Tasks
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #11064 +/- ##
==========================================
+ Coverage 58.44% 58.50% +0.06%
==========================================
Files 216 216
Lines 17248 17269 +21
Branches 3520 3524 +4
==========================================
+ Hits 10080 10103 +23
+ Misses 6660 6651 -9
- Partials 508 515 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Removes the per-row
Row/Vec<TableValue>intermediate from the CubeStore CSV file-import path, appending parsed values straight into the Arrow column builders. This drops the allocations that scale with row count — oneVec<TableValue>per row (unconditional) and theTableValue::Stringcopy per string cell (the most common column type) — to relieve allocator pressure on large imports.Changes
do_importnow drives the CSV line stream through a sharedCsvImportParserand appends each field directly into itsArrayBuilder; strings go straight intoStringBuilder, skipping theTableValue::Stringallocation.CsvImportParserand shared between the builder path and theRow-producing path (still used by HTTP inline tables), so the two cannot diverge.finish()).parse_column_value_str+append_valueare reused for all non-string types, so type mapping and null semantics are unchanged.Testing
Rowpath (compared through identical Arrow reconstruction), with and without a header.create_table_with_csv*(5) andcreate_table_with_location*(6, incl. gzip, reordered columns, invalid-digit error path, and all three HLL flavors).