Skip to content

Add JSONL support to dolt table {import,export}#10577

Merged
coffeegoddd merged 5 commits intomainfrom
db/jsonl
Feb 26, 2026
Merged

Add JSONL support to dolt table {import,export}#10577
coffeegoddd merged 5 commits intomainfrom
db/jsonl

Conversation

@coffeegoddd
Copy link
Copy Markdown
Contributor

@coffeegoddd coffeegoddd commented Feb 25, 2026

Adds JSONL (.jsonl / --file-type jsonl) support for both dolt table export (newline-delimited rows reusing existing JSON serialization) and dolt table import (streaming JSONL reader), with updated CLI help plus unit and Bats integration tests.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds JSONL export support to dolt table export by introducing a new jsonl data format that reuses existing JSON row serialization, along with unit + integration test coverage and updated CLI help text.

Changes:

  • Add .jsonl / --file-type jsonl support to mvdata export writer selection.
  • Add Go unit tests verifying newline-delimited JSON output using the existing JSON writer with custom header/separator/footer.
  • Add Bats integration tests covering JSONL export (including JSON / binary / quoting edge cases) and update CLI help text.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
integration-tests/bats/export-tables.bats Adds JSONL export assertions and edge-case coverage via Python JSON parsing.
go/libraries/doltcore/table/typed/json/writer_jsonl_test.go New unit tests validating JSONL output behavior via NewJSONWriterWithHeader.
go/libraries/doltcore/mvdata/file_data_loc.go Adds jsonl parsing + writer creation path for export.
go/libraries/doltcore/mvdata/data_loc_test.go Extends data location tests to include .jsonl / jsonl.
go/libraries/doltcore/mvdata/data_loc.go Introduces JsonlFile data format and wiring for extension inference.
go/cmd/dolt/commands/tblcmds/export.go Updates dolt table export help text to mention JSONL and supported formats.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +50 to +51
case "jsonl", ".jsonl":
return JsonlFile
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DFFromString now treats jsonl as a valid DataFormat, but FileDataLocation.NewReader does not handle JsonlFile. This means dolt table import --file-type jsonl ... will pass the file-type validation (since DFFromString no longer returns InvalidDataFormat) and then fail later with a generic "unsupported format" error. Either add JSONL import support, or keep jsonl out of import validation (e.g., validate allowed file types per-command) / return a clear error when JsonlFile is used for reading.

Suggested change
case "jsonl", ".jsonl":
return JsonlFile

Copilot uses AI. Check for mistakes.

{{.EmphasisLeft}}.json{{.EmphasisRight}} exports a single JSON object containing a {{.EmphasisLeft}}rows{{.EmphasisRight}} array; {{.EmphasisLeft}}.jsonl{{.EmphasisRight}} exports one JSON object per line.

See the help for {{.EmphasisLeft}}dolt table import{{.EmphasisRight}} as the options are the same.
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The help text says "See the help for dolt table import as the options are the same", but export now supports jsonl (and also lists sql / parquet) while table import help and validation do not list / support these formats. This is likely to confuse users; consider either updating the wording to avoid claiming parity with import, or explicitly calling out which --file-type values are valid for export vs import (and that stdout export is limited to csv/psv).

Suggested change
See the help for {{.EmphasisLeft}}dolt table import{{.EmphasisRight}} as the options are the same.
When writing to stdout (omitting {{.LessThan}}|file{{.GreaterThan}} or using {{.EmphasisLeft}}-{{.EmphasisRight}}), only {{.EmphasisLeft}}csv{{.EmphasisRight}} and {{.EmphasisLeft}}psv{{.EmphasisRight}} are supported.
For information on importing data, see the help for {{.EmphasisLeft}}dolt table import{{.EmphasisRight}}; note that its supported file types and options differ from export.

Copilot uses AI. Check for mistakes.
@coffeegoddd
Copy link
Copy Markdown
Contributor Author

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
4196a34 ok 5937471
version total_tests
4196a34 5937471
correctness_percentage
100.0

@coffeegoddd coffeegoddd changed the title Add JSONL support to dolt table export Add JSONL support to dolt table {import,export} Feb 25, 2026
@coffeegoddd coffeegoddd requested a review from Copilot February 25, 2026 23:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +93 to +95
var err error
r.sampleRow, err = r.ReadSqlRow(context.Background())
return err == nil, nil
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VerifySchema drops any error returned by ReadSqlRow (it returns nil error even when ReadSqlRow fails). This can mask malformed JSON / conversion errors during schema verification and cause later failures with less actionable context. Return the actual err (and only keep sampleRow when err == nil) so callers see the correct failure reason.

Suggested change
var err error
r.sampleRow, err = r.ReadSqlRow(context.Background())
return err == nil, nil
sampleRow, err := r.ReadSqlRow(context.Background())
if err != nil {
return false, err
}
r.sampleRow = sampleRow

Copilot uses AI. Check for mistakes.
}

func (r *JSONLReader) ReadRow(ctx context.Context) (row.Row, error) {
panic("deprecated")
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method panics at runtime. Since JSONLReader is declared to implement table.SqlTableReader, any code path that still calls ReadRow (even indirectly) will crash the process. Prefer returning a non-panicking error (or implement the method properly) to avoid a hard failure.

Suggested change
panic("deprecated")
return nil, fmt.Errorf("ReadRow is deprecated for JSONLReader; use ReadSqlRow instead")

Copilot uses AI. Check for mistakes.

func resolveJSONSchema(dEnv *env.DoltEnv, root doltdb.RootValue, opts interface{}) (schema.Schema, error) {
var sch schema.Schema
jsonOpts, _ := opts.(JSONOptions)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolveJSONSchema silently ignores a failed type assertion (jsonOpts, _ := opts.(JSONOptions)). If a non-JSONOptions value is ever passed, this will fall through with zero-values (e.g., empty TableName) and produce misleading downstream errors. Check the ok result and return a clear error when opts is non-nil but not JSONOptions.

Suggested change
jsonOpts, _ := opts.(JSONOptions)
jsonOpts, ok := opts.(JSONOptions)
if opts != nil && !ok {
return nil, fmt.Errorf("invalid JSON options type: %T", opts)
}

Copilot uses AI. Check for mistakes.
Comment on lines +79 to +84
if r.closer != nil {
err := r.closer.Close()
r.closer = nil
return err
}
return errors.New("already closed")
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning an error on a second Close() makes this reader non-idempotent, which can be surprising in Go (where Close is commonly safe to call multiple times, especially with layered defers). Consider returning nil when already closed to make cleanup more robust.

Suggested change
if r.closer != nil {
err := r.closer.Close()
r.closer = nil
return err
}
return errors.New("already closed")
if r.closer == nil {
return nil
}
err := r.closer.Close()
r.closer = nil
return err

Copilot uses AI. Check for mistakes.
@coffeegoddd
Copy link
Copy Markdown
Contributor Author

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
ca3a329 ok 5937471
version total_tests
ca3a329 5937471
correctness_percentage
100.0

@coffeegoddd coffeegoddd requested a review from jycor February 26, 2026 00:45
@coffeegoddd
Copy link
Copy Markdown
Contributor Author

fixes #10573

Copy link
Copy Markdown
Contributor

@jycor jycor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

coffeegoddd and others added 2 commits February 25, 2026 17:02
Co-authored-by: James Cor <jcor@ucsd.edu>
Co-authored-by: James Cor <jcor@ucsd.edu>
@coffeegoddd
Copy link
Copy Markdown
Contributor Author

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
06da432 ok 5937471
version total_tests
06da432 5937471
correctness_percentage
100.0

@coffeegoddd
Copy link
Copy Markdown
Contributor Author

@coffeegoddd DOLT

test_name from_latency_p95 to_latency_p95 percent_change
tpcc-scale-factor-1 61.08 61.08 0.0
test_name from_server_name from_server_version from_tps to_server_name to_server_version to_tps percent_change
tpcc-scale-factor-1 dolt c31b3b9 38.23 dolt ae32b5d 37.66 -1.49

@coffeegoddd coffeegoddd merged commit 41d9b25 into main Feb 26, 2026
25 checks passed
@coffeegoddd coffeegoddd deleted the db/jsonl branch February 26, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants