Illustrative demo using fictional data, without actual product screens, data, or SQL.
Internship (Jun – Aug 2026)
NL2SQL Quality
A feature that lets people look up business data in plain language, without knowing SQL.
During my internship at a Korean security solutions company, I improved the SQL quality of a feature that answers business-data questions asked in plain language. I traced why generated SQL ran yet gave wrong business answers, and rebuilt the setup so shared business rules live in the AI instructions and question-specific approaches live in the examples.
ResultConditions repeated in every example (excluding deleted data, picking the latest history, product scope) now live in one shared instruction. On the questions used for tuning, the generated SQL now carries the expected conditions.
Note: Validation was done within the set of questions used to adjust the configuration. Evaluating it on questions not used for adjustment is future work.
Period
2026.06.29 - 2026.08.31
Format
Internship
Project
Internship at a security software company
Role
Traced why generated SQL ran yet gave the wrong business answer, using product screens, execution logs, table definitions, and existing SQL, then rebuilt the AI instructions and examples.
Tech stack
PostgreSQL, LLM prompt design
Asking business data questions without writing SQL
From June 29 to August 31, 2026, I interned at a Korean security solutions company. I worked on a feature where a person asks a question in plain language and AI writes SQL against a PostgreSQL business database to answer it, so people who do not know SQL can still pull business data themselves.
This was not an assigned task. I noticed the problem while reading the generated SQL, and took it on myself with my supervisor's permission.
SQL that runs is not always the right answer
Most generated SQL ran without errors, so the logs showed success. Read with business knowledge, though, some of the results were wrong.
The cause was business rules, not SQL syntax. Deleted data is kept as rows marked deleted rather than removed. Miss that mark, and data that should be gone shows up in the answer.
History works the same way: the same item has many point-in-time records. Unless the query picks the latest one, old and new states come back side by side. And if the query ignores which product's data is in scope, unrelated data ends up in the totals.
All of these are valid SQL that runs fine. Success or failure of execution cannot catch them; you have to decide first what counts as the right business answer.
An example on a fictional schema
The real product and data cannot be shown, so I reproduced the same kind of error on fictional tables.
The question is "Show me the hostnames of assets with Intel CPUs." Both queries run without errors.
Before: runs, but the answer is wrong
SELECT i.hostname, c.cpu_manufacturer
FROM asset_info_history i
JOIN asset_cpu_history c
ON c.asset_id = i.asset_id
WHERE c.cpu_manufacturer ILIKE '%Intel%';
After: business rules applied
SELECT i.hostname, c.cpu_manufacturer
FROM security_assets a
JOIN asset_info_current i
ON i.asset_id = a.id
JOIN asset_cpu_current c
ON c.asset_id = a.id
AND c.history_id = i.history_id
WHERE a.is_deleted = FALSE
AND c.cpu_manufacturer ILIKE '%Intel%';
Illustrative example on a fictional schema. Before: the history tables are joined on asset ID alone, so assets that once had an Intel CPU still appear, rows under hostnames from before a rename come back, and deleted assets remain. After: the query uses the current-state tables, joins basic info and CPU only from the same collection run (history_id), and excludes deleted assets. The trade-off: an asset whose info and CPU were collected in different runs drops out of the result.
Backing each rule with four sources
Table names alone were not enough to decide the rules. A name does not say whether a table holds the current state or point-in-time records, or how deletion is represented.
So I cross-checked four sources: the product screens, the existing SQL behind those screens, queries recorded in the execution logs, and the table definitions (DDL). I confirmed what each screen shows and which conditions its existing SQL filters on, and only turned a guess from a name into a rule once the real processing backed it up.
Rules in the instructions, approaches in the examples
The obvious approach is to keep adding the needed conditions to the AI's worked examples. But then every new kind of question means writing the deleted-data filter and the latest-history rule into yet another example.
That causes three problems. The same condition is duplicated in every example. One rule change means editing every example. And when some examples include a condition and others do not, that inconsistency shows up directly in the generated SQL.
So I proposed splitting the roles. Business rules shared by every question, namely excluding deleted data, using the latest history, and the product scope, are written once in the AI instructions. The examples keep only what is specific to each question: which tables to join and how to aggregate.
Adding to examples works quickly while there are few of them. As they grow, so does the number of places to fix, and every rule change means reviewing all of them. That is why I chose to keep the rules in one place.
How the AI instructions and examples are organized (structure only, no actual text). Shared business rules sit in one place in the instructions; each question's approach sits in its example (illustrates the section above).
Same questions, before and after side by side
After rebuilding the instructions and examples, I ran the same questions through the old and new setups and compared the generated SQL side by side, checking whether each query carried the conditions expected for that question, such as the deleted-data filter and latest-history selection. I shared the comparison with my supervisor.
The questions I compared were the ones used while tuning the setup. Next time, I would also prepare questions that were not used for tuning and run the same comparison.
Repository, SQL, prompts, and evaluation data are private because this was an internal company project.