A Practical Guide to LLM-Driven Data Engineering: From Requirements to Reliable Pipelines
This article presents a practical workflow for using large language models in data engineering without losing control of long-running tasks. Instead of handing a full requirement to the model and expecting end-to-end delivery, the recommended pattern is "the workflow is owned by the developer, the model executes it": define the process and data structures first, then split each step into clearly bounded, independently verifiable subtasks. Using a stock backtesting data ingestion example, the guide walks through making the symbol list machine-readable, localizing API documentation and running per-endpoint connectivity tests, designing normalized and extensible database schemas, adding structured progress logging and resumable runs, and applying engineering safeguards such as timeouts, small commits, idempotent writes, reconciliation checks, and human approval gates. A reusable collaboration checklist and closing notes on hosting and observability are included.
1. The Problem: Why a “One-Sentence Requirement” Goes Off the Rails
When you ask a large language model to handle a data engineering task, one of the most common failure modes is dumping the entire requirement at once and expecting end-to-end delivery. What you often get instead is a messy directory structure, inconsistent field naming, missing error handling, and sometimes a silent stall halfway through. The root cause is not model capability. It is a mismatch between task granularity and verification cadence: generative models accumulate drift across long chains of work, and without intermediate checkpoints, that drift never gets cut off in time.
A more reliable pattern is to let the workflow be self-sustaining and let the model execute it. As the developer, you work out the process and the data structures first, then compress each step into a subtask with clear boundaries that can be verified on its own. The example below uses “pulling market data for a stock buy/sell backtesting system” to lay out a complete, end-to-end path.
2. Step 1: Make the Instrument List Machine-Readable
Do not tell the model to “go pull the stocks.” Instead, ask it to produce a structured list, then confirm it manually. Example:
{"symbols": [{"code": "600000.SH", "name": "Example A", "market": "SH"},{"code": "000001.SZ", "name": "Example B", "market": "SZ"}],"adjust": "qfq","freq": ["daily", "minute"]}
Three points matter here. First, every code must carry a market suffix to avoid ambiguity between identically named instruments. Second, metadata such as the adjustment method and frequency must be declared explicitly rather than hidden inside the code. Third, save the list to disk as a configuration file, and have every subsequent step read only that file, creating a single source of truth.
3. Step 2: Read the API Docs First, Make Capability Boundaries Checkable
Before writing any collection code, localize the data source documentation: fetch the official documentation and organize it into a local Markdown file with field descriptions, rate limits, error codes, and sample responses. Then have the model generate a separate connectivity test for each endpoint, run them one by one, and roll the results into a test report.
A recommended report structure:
| Endpoint capability | Available | Key fields | Per-request limit | Notes |
|---|---|---|---|---|
| Daily bars | Pass | Open, high, low, close, volume | Depends on account tier | Requires adjustment parameter |
| Minute bars | Pass | Timestamp, price | Smaller | Pagination recommended |
| Instrument reference | Pass | Code, name, listing date | — | Used to validate the list |
The value of this step is turning “can we use it?” from a guess into a conclusion, so the model does not write code against imagined endpoint parameters. Inject all credentials through environment variables or local configuration; never write them into source code or logs.
4. Step 3: Keep the Database Design Normalized and Extensible
The storage layer determines how flexible your later backtesting can be. A recommended minimal viable design:
CREATE TABLE instrument (code VARCHAR(16) PRIMARY KEY,name VARCHAR(64) NOT NULL,market VARCHAR(8) NOT NULL,list_date DATE);CREATE TABLE bar_daily (code VARCHAR(16) NOT NULL,trade_date DATE NOT NULL,open DECIMAL(18,4),high DECIMAL(18,4),low DECIMAL(18,4),close DECIMAL(18,4),volume BIGINT,adjust VARCHAR(8) NOT NULL,PRIMARY KEY (code, trade_date, adjust));CREATE TABLE bar_minute (code VARCHAR(16) NOT NULL,ts TIMESTAMP NOT NULL,price DECIMAL(18,4),volume BIGINT,PRIMARY KEY (code, ts));
The design principles: primary keys deduplicate naturally and support idempotent writes on repeated pulls; including the adjustment method in the primary key prevents different conventions from overwriting each other; keeping market data separate from metadata makes partitioning and archiving easier; and using fixed-point numbers instead of floating point for prices prevents accumulated error from distorting backtesting conclusions.
5. Step 4: Make Execution Observable
Long-running tasks must be visible. Require the model to emit structured progress rather than spin silently, for example:
def fetch_one(code, logger):total, done = 0, 0try:for page in iter_pages(code): # pagination is bounded by the endpoint limittotal += len(page)upsert_daily(page) # idempotent writedone += len(page)logger.info("progress", extra={"code": code, "done": done})except TransientError as e:logger.warning("retry", extra={"code": code, "err": str(e)})raise
Three supporting measures: resumable runs, using a cursor table to record the last successful date for each instrument; rate limiting with exponential backoff to respect endpoint quotas; and log leveling, with progress at INFO and recoverable exceptions at WARNING so issues are easy to trace afterward.
6. Engineering Responses to “Silent Hangs” and Stability Risk
A newly released model may produce no output for a long stretch during lengthy tasks. Rather than repeatedly interrupting by hand, remove the risk at the process level:
- Per-task timeout: set a wall-clock timeout for each call, and on timeout abort and roll back to the last checkpoint;
- Small commits: write to the database after each instrument or each page, so a failure costs only one step;
- Idempotency first: base all writes on primary-key upserts, so reruns have no side effects;
- Reconciliation checks: after pulling, compare record counts, date ranges, and null rates, and automatically re-pull on anomalies;
- Human gates: require manual approval at key points (list confirmation, schema confirmation, full-run kickoff).
7. A Reusable Collaboration Checklist
- Define the process and data structures first, then let the model write code;
- Localize documentation + run per-endpoint connectivity tests + produce a test report;
- Externalize configuration and credentials, with zero secrets in code;
- Design tables for extension from the start: primary keys, partitioning, convention fields;
- Structure progress, make logs searchable, keep tasks resumable;
- Produce a verifiable artifact at every step (list, report, schema, validation results);
- When something breaks, narrow the granularity first; do not expand the task scope.
8. Conclusion
The right role for a large language model in data engineering is an efficient executor, not a process designer. By front-loading endpoint capability verification, storage standards, observability, and human checkpoints, you keep the speed advantage of generative tools while pushing the probability of losing control into an acceptable range. If you need managed operation, you can deploy the collection and validation tasks to a container platform, use a message queue for task distribution, and rely on logging services plus monitoring and alerting for full-chain tracing, building a stable, extensible market data foundation without locking into any specific vendor.
