feat(databases): Import Data modal — samples, CSV/JSON files, and URL loads#1412
Open
dawsontoth wants to merge 3 commits into
Open
feat(databases): Import Data modal — samples, CSV/JSON files, and URL loads#1412dawsontoth wants to merge 3 commits into
dawsontoth wants to merge 3 commits into
Conversation
… loads Replaces the bare-bones Import CSV modal with an Import Data flow (#1292): - Sample Datasets: three bundled starter datasets (dogs, books, animals) loaded via csv_data_load, so they work on air-gapped instances too - Import from File: CSV via csv_data_load, JSON via insert - Load from URL: csv_url_load fetched by the instance - Missing tables are created automatically (primary key id) before loading - CSV loads now poll get_job until the job finishes instead of telling the user to wait and refresh - Second entry point in the Databases sidebar so import is available before any table exists Connect-to-database / live sync from the issue mockup needs backend support and is intentionally out of scope. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request replaces the CSV-only import modal with a comprehensive ImportDataModal that supports importing data from local CSV/JSON files, remote URLs, and pre-loaded sample datasets. It also introduces utility functions for parsing JSON records, a job polling mechanism to track asynchronous imports, and corresponding unit tests. Feedback on these changes includes improving the resilience of the job polling loop against transient network errors, handling potential FileReader failures when uploading files, and adding an error handler to the import mutation to provide user feedback on failures.
When the import target already exists and has columns beyond the primary key and system timestamps, the Sample Datasets picker gains a 'Random Data' option (under a 'This table' group) with a row-count input (1-1000, default 25). Values come from the column's declared type when the table has one, falling back to column-name heuristics (email, name, age, price, boolean-ish, dates, ...) for schemaless tables. The primary key is omitted so Harper assigns it. Verified end-to-end against a stage test cluster: Dogs sample import created data.dog and loaded 15 rows (csv_data_load + get_job polling), then Random Data inserted 7 heuristic rows into it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review feedback: waitForJob now tolerates transient get_job failures (up to 5 consecutive) instead of failing an import whose job is still running, and the file dropzone reports FileReader errors via a toast. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1292.
What
Replaces the bare-bones Import CSV modal with an Import Data flow modeled on the issue's mockups, with three methods:
csv_data_load/insertcsv_data_load/insertcsv_url_loadUX details
id) when the target doesn't exist, with an inline heads-up alert. Picking a sample dataset auto-fills its suggested table name.job_idthat the old modal ignored ("Please wait a few moments then refresh the table"). The new flow pollsget_jobuntil the job completes, then refreshes the table tree and navigates to the imported table — data is just there when the modal closes. Job errors (e.g. malformed CSV) surface as real error toasts.?rawimports (~6 KB total), so they work on self-hosted/air-gapped instances that can't fetch external URLs.Scope notes
The mockup's Connect to Database (mongodump,
.zip, live sync) has no supporting operations in Harper today, so it's intentionally left out rather than shipped as a dead-end UI; the method picker makes it easy to add once the backend exists.import_from_s3is also a candidate for a follow-up method.Testing
get_jobpolling (waitForJob), JSON upload parsing, random-record generation (types, heuristics, skipped columns), and sample-dataset CSV validity (format, unique ids, consistent columns). Full suite green; tsc, oxlint, dprint clean.data.dogand loaded 15 records (create_table→csv_data_load→get_jobpolling → auto-navigate), and Random Data then inserted 7 generated rows into that table with sensible per-column values. Also exercised both entry points, method switching, dataset auto-fill, and the new-table alert.🤖 Generated with Claude Code