The interview problem
Let analysts ask questions of approved datasets without executing arbitrary generated SQL.
Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.
1. Scope and worked approach
Retrieve authorized schema, generate a typed query candidate, parse it and enforce an allowlisted read-only subset. Execute under least-privilege credentials with row and time limits. Require clarification for ambiguous metrics and show the interpreted definition before costly queries.
2. Trace the design or derivation
Question and authorized schema → candidate AST → policy checks → bounded execution → cited result
Separate a proposed query from execution approval where the customer requires it. Cache by schema, authorization scope and metric version. Never infer that a successful run means the answer matches the user’s intended time zone, denominator or currency.
3. Calculate the example
A join of 1,000 orders to 3,000 order lines produces 3,000 rows. Summing order totals after that join can triple revenue when each order has three lines; valid SQL is not a correct business answer.
4. Failure cases and trade-offs
A parser alone does not enforce row authorization. A read-only query can still be expensive or expose restricted data. Textual similarity to a reference query misses equivalent plans and semantic errors.
5. Validation, follow-ups and self-review
Use fixture databases with known answers, restricted rows and adversarial prompts. Follow-up: how do schema changes invalidate cached queries? Self-review: cover semantics, permissions and resource bounds.
Sources and related practice
Technical reference: arxiv.org — RAT-SQL schema-aware text-to-SQL; execution safeguards are original.
Source publication/update: 2019-11-10; revised 2021-08-24. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.
Continue with Design a document question-answering system; Map enterprise permissions into retrieval access.
Continue your preparation
Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.