A Practical Guide to LLM-Driven Data Engineering Workflows
This guide explains why handing an entire data engineering requirement to a large language model in one shot tends to fail, and presents a more reliable alternative: humans define the workflow, the model executes one step at a time, and humans verify each step. It walks through a five-stage pipeline breakdown—entity clarification, localizing API documentation, probing API availability, storage design, and ingestion with observability—along with example prompts, a sample schema, and structured logging patterns, plus common pitfalls and how to avoid them.
1. The Problem: Why “One Big Prompt” Spirals Out of Control
In real data engineering work, developers increasingly rely on AI coding tools to scaffold projects, wire up API calls, and land data in storage. One failure mode keeps recurring: handing the model every requirement at once and expecting end-to-end delivery. The usual result is a messy directory structure, missing error handling, inconsistent field naming, and sometimes a model that contradicts its own earlier design decisions within the same generation.
The root cause is not model capability. It is task granularity and verification cadence. Data pipelines are strongly dependency-driven engineering: whether an upstream API is available, whether fields are stable, how primary keys are defined, and how to switch between incremental and full loads—these decisions are tightly coupled. A single-shot delivery compresses all coupled decisions into one step, leaving the model no external feedback to correct course, so errors get amplified.
A more reliable collaboration pattern is therefore: humans define the process, the model executes a single step, humans accept the result. Developers own the goal, the constraints, and the acceptance criteria; the model produces runnable code within clear boundaries; and every step leaves behind an inspectable artifact.
2. Overview: Cut the Big Task into Verifiable Small Steps
Split a data pipeline into five stages, each with its own deliverable and acceptance criteria:
- Entity clarification: confirm the instrument list, time range, and field definitions.
- Documentation localization: persist the API specs to local files as the single source of truth.
- API availability verification: make a minimal call to each API and output a test report.
- Storage design: settle table conventions, primary keys and indexes, and extension slots.
- Ingestion and observability: implement paginated fetching, progress output, retry on failure, and resume from checkpoints.
The key value of this split is rollback. When step 3 reveals that an API is unusable, you only replace that API’s implementation instead of tearing down the whole structure.
3. Step 1: Entity Clarification and Human Confirmation
Do not hand “process these trade tickets” straight to the model. First have it extract instrument names and codes into a list for confirmation, and review that list manually. Example prompt:
Extract all instrument names and codes from the trade tickets above andoutput them as a table with: index, name, code, market, notes.Do not perform any data fetching.
The artifact of this step should be plain text or a table that can be diffed. Confirming it manually before moving on prevents upstream recognition errors from propagating through the entire pipeline.
4. Step 2: Localize API Documentation and Probe the APIs
Fetching the API specs and persisting them as local Markdown is the key move for containing uncertainty. Once the documentation is local, the model treats the file as its only basis, which reduces the risk of inventing parameters from memory.
Fetch the content at the given API documentation URL into a local Markdownfile. Preserve the parameter tables, response field tables, error codes, andrate limit notes. Do not trim or summarize.
Then probe the APIs: write a minimal runnable call for each one that verifies only “does it connect, and what does the response look like,” with no business processing, and aggregate the results into a test report.
Based on the local API documentation, generate one minimal call script perAPI, run them one by one, and output a report: API name, success or not,elapsed time, list of response fields, error message.Do not retry a failed item more than once.
The report is the basis for later selection. In practice, some APIs require credits or permissions and some are rate limited; only real testing determines the usable set.
5. Step 3: Storage Design That Is Consistent and Extensible
A few general principles apply to landing data: use lowercase with underscores for database and table names; give every table a unique primary key; store time fields as timestamps with timezone semantics or standard dates; keep the raw response body (for example, a JSON text column) for traceability; index high-frequency queries; and reserve extension fields to avoid frequent schema changes.
CREATE TABLE daily_bar (symbol VARCHAR(16) NOT NULL,trade_date DATE NOT NULL,open DECIMAL(18,6),high DECIMAL(18,6),low DECIMAL(18,6),close DECIMAL(18,6),volume BIGINT,raw_payload TEXT,updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,PRIMARY KEY (symbol, trade_date));CREATE TABLE intraday_tick (symbol VARCHAR(16) NOT NULL,trade_time TIMESTAMP NOT NULL,price DECIMAL(18,6),volume BIGINT,raw_payload TEXT,PRIMARY KEY (symbol, trade_time));
Daily bars use “symbol + trade date” as the primary key, which is naturally idempotent; intraday data uses “symbol + time,” so repeated fetches produce no dirty data. This is what makes safe checkpoint resume possible later.
6. Step 4: Ingestion Implementation and Visible Progress
The ingestion stage must be observable. Have the model emit structured logs rather than scattered prints:
[2026-01-01 10:00:00] symbol=600xxx progress=12/50 pages=2/5 rows=1200 status=ok[2026-01-01 10:00:03] symbol=600xxx progress=13/50 status=retry attempt=1 reason=timeout
The implementation should include rate limiting with backoff, a retry cap, single-instrument failures that do not affect the whole run, cursor or date-range chunking, and batched commits on write. Sample code:
for i, sym in enumerate(symbols, 1):for chunk in split_by_date(start, end, step_days=30):for attempt in range(3):try:df = fetch_daily(sym, chunk)upsert(daily_bar, df) # idempotent write keyed on primary keylog(i, len(symbols), "ok")breakexcept Exception as e:log(i, len(symbols), f"retry {attempt}", e)sleep(backoff(attempt))
7. Common Problems and How to Avoid Them
- Long silence with no response: give each single-step task a timeout and heartbeat logs; abort and rerun when there is no output instead of waiting indefinitely.
- Field drift: treat the local documentation as authoritative, validate against a field whitelist before writing, and route unknown fields to extension columns.
- Duplicate data: rely on primary keys and idempotent writes rather than “delete then insert.”
- Context pollution: supply only the necessary files and snippets at each step; a whole-database context scatters attention.
- Missing acceptance: require the model to state an executable verification method at every step, such as row count checks or sampled comparisons.
8. Conclusion
Treating a large language model as a senior assistant that executes one step at a time, rather than an end-to-end delivery vendor, is the most economical risk control strategy in data engineering practice. Humans define the process, localized documentation serves as the source of truth, APIs are probed before selection, storage is built on idempotent primary keys, and structured logs keep the process observable—together this combination converges the uncertainty of generative tools into an acceptable range, so the pipeline both runs and stays maintainable.
