torder: Text2SQL with dual approval
Korean Original · AI translated and organized · AI implementation (FDE not disclosed)
Case Overview
Business Problem
"Why did yield drop yesterday" simultaneously involves the time window, rework definition, product, and operation. Even if the same sentence can generate executable SQL, it may produce a business-incorrect denominator or duplicate join results. Business intent and database syntax must be validated separately.
Publicly disclosed AI solutions
Enable business personnel to query order, store, and advertising data in natural language, reducing reliance on the technical team for ad hoc data questions.
Core Engineering Findings
Engineering Analysis by This LibraryDual approval separately confirms business semantics and SQL execution risk
Correct SQL syntax cannot prove business semantic correctness, nor can it prevent excessive data scanning; letting users see only SQL makes it easy to miss intent changes.
Engineering analysis · View basisTechnical Architecture
Public solution summaryThe source uses LangGraph, Bedrock, Athena, S3 / S3 Vectors; it retrieves table schemas, query patterns, and terminology, fills in table dependencies, and executes after intent confirmation, SQL validation, and SQL confirmation.
View the complete architecture and reference data flowKey engineering trade-offs
Engineering Analysis by This LibraryThe source first confirms understanding, then discloses the SQL to confirm execution; it retrieves schema, query patterns, and terminology in stages, and uses Athena EXPLAIN. It is recommended that approval be bound to the SQL hash, identity, cost budget, and schema version.
Two interactions increase waiting and cognitive burden; updating the business dictionary and templates requires expert investment.
In-depth Technical AnalysisOutcomes and Verification Boundaries
Production implementationThe source provides implementation details such as dual human confirmation, staged retrieval, and SQL validation, but does not give independently verifiable manufacturing benefits.
Source verified · Public cases · Benefits not independently accepted
The original business belongs to restaurant technology. Manufacturing shifts, rework, operation granularity, and plant permissions need to be redesigned; EXPLAIN cannot prove business result correctness.
Complete results criteria and applicable boundariesIn-depth Technical Analysis Architecture, Trade-offs, and Transfer Conditions
Business Background and Process
Research Analysis"Why did yield drop yesterday" simultaneously involves the time window, rework definition, product, and operation. Even if the same sentence can generate executable SQL, it may produce a business-incorrect denominator or duplicate join results. Business intent and database syntax must be validated separately.
- Role
- The original case is oriented toward business data Q&A; the migration plan is oriented toward production supervisors, quality engineers, data engineers, and data permission owners.
- Reproduction scope
- First use synthetic MES data to reproduce single-plant output, first-pass yield, and work order queries. Read-only database views, do not execute modification statements, and do not connect directly to the production database.
- 1The user asks a question; first clarify the plant, date, shift, and metric definition.
- 2Retrieve table schemas, relationship rules, and terminology to form a confirmable query intent.
- 3Generate read-only SQL, perform permission, scan volume, and syntax checks, then have the user confirm.
- 4Execute the query and display units, filter conditions, and data time; follow-up questions use the confirmed context.
Engineering Problems and Transferable Lessons
Key Engineering Insightinsight- Special Issues
- Concepts such as impressions, orders, and last month in natural language must be mapped to the correct tables, fields, time zones, and business filter conditions.
- Why Ordinary Architecture Is Not Enough
- Correct SQL syntax cannot prove business semantic correctness, nor can it prevent excessive data scanning; letting users see only SQL makes it easy to miss intent changes.
- Key technical choices
- The source first confirms understanding, then discloses the SQL to confirm execution; it retrieves schema, query patterns, and terminology in stages, and uses Athena EXPLAIN. It is recommended that approval be bound to the SQL hash, identity, cost budget, and schema version.
- Costs and trade-offs
- Two interactions increase waiting and cognitive burden; updating the business dictionary and templates requires expert investment.
- Failure conditions
- If approved SQL is rewritten, user permissions change, schema drift occurs, or partition filtering is omitted, re-approval or execution refusal is required.
- Transferable experience
- Evaluate schema linking, business result correctness rate, and scan cost separately; EXPLAIN is not business correctness acceptance.
Public materials support the problem background; technical supplements are engineering inferences by this library. Related original text:
Original disclosureSource verifiedfact:1Original disclosureSource verifiedfact:2Technical Architecture and Data Flow
Original text / solution listed separatelyOriginal architecture summary
The source uses LangGraph, Bedrock, Athena, S3 / S3 Vectors; it retrieves table schemas, query patterns, and terminology, fills in table dependencies, and executes after intent confirmation, SQL validation, and SQL confirmation.
The above is a source summary of the restaurant technology data platform. The MES business model, query agent, permission isolation, and acceptance dataset below are migration designs; they are not a manufacturing system already delivered by torder.
Suggested Architecture for Reproduction
The following is the research design and does not represent the complete implementation of the enterprise's internal system.
- 1Confirm business intent
Clarify metrics, granularity, plant, and time range, and return ambiguous questions to the user.
- 2Retrieval and dependency completion
From table schemas to query examples, then fill in missing related tables and business terminology.
- 3Generate and check SQL
Validate read-only statements, authorized views, partition filtering, and resource budget, then check syntax.
- 4Execute after confirmation
Display the Chinese query plan and SQL; if the approved content changes, re-confirmation is required.
- 5Explanation and follow-up questions
Results are accompanied by metric definitions, time window, data freshness, and query number; no data cannot be interpreted as zero.
Suggested Data and System Interfaces
| Business Object | Join key / criteria | Suggested Sources | Purpose in the process |
|---|---|---|---|
| Production work orders | order_id, plant_id, product_id, planned / actual quantity | Synthetic ERP / MES read-only views | Determine the order dimension and plant data scope |
| Operations and quality results | order_id, operation_id, lot_id, pass / rework status | Synthetic MES / QMS read-only views | Define first-pass yield to prevent duplicate counting from multi-operation JOINs |
| Shift calendar | plant_id, shift_id, start and end time, time zone | Synthetic shift configuration table | Convert "last night's shift" into an explicit cross-day time window |
| Metrics and query knowledge | Metric name, numerator and denominator, granularity, table dependencies, reviewed version | Business glossary and reviewed SQL examples | Fill in relationship dependencies to reduce metric definition drift for same-named metrics |
Key design trade-offs
Research AnalysisDoes a SQL query count as a correct answer if it can execute?
Suggested choice:Evaluate the result set, business metric definitions, and permissions simultaneously.
Basis for judgment: EXPLAIN can detect some syntax issues, but cannot prove that the yield denominator, cross-day shifts, and JOIN granularity are correct.
Costs and boundaries: Domain experts are needed to annotate reference results; evaluation cost is higher than only counting SQL execution success rate.
Have business users approve a long block of SQL?
Suggested choice:The first confirmation covers metrics and scope; the second displays both the Chinese query plan and SQL.
Basis for judgment: Non-technical personnel can verify intent, but may not be able to identify SQL risks; permissions and read-only restrictions are still enforced by the system.
Costs and boundaries: Increases interaction time; high-frequency reviewed queries can use controlled templates to simplify approval.
Put all table schemas into the prompt at once?
Suggested choice:Retrieve related tables and fill in dependencies, retaining the reviewed metric semantic layer.
Basis for judgment: Full context easily misses relationships or mixes up similar fields; cross-table dependencies must be complete rather than merely increasing the number of similarity-based retrievals.
Costs and boundaries: Examples, metric versions, and dependencies must be maintained; new fields going live should trigger regression evaluation.
Engineering Failure Conditions
Exceptions and Degradation
Supplement retrieval and retry in a limited way; if it still fails, return the query number and missing information to a data engineer.
The queryable scope is determined by server-side permissions; permissions self-declared by the model or user cannot be accepted.
Display no matching records and data not updated separately; do not convert NULL or empty sets into zero output.
When it is suitable for adoption, and how value is measured
Research Recommendations by This Library- Data and Organizational Prerequisites
- Metric definitions, shifts/time zones, table granularity, join keys, and access permissions are clear; business personnel can provide representative questions and correct answers. Recommended key relationships for this case: production work orders (order_id, plant_id, product_id, planned / actual quantity); operations and quality results (order_id, operation_id, lot_id, pass / rework status).
- Division of labor among AI, rules and humans
- AI clarifies intent and explains query results; statistics, metric definition conversion, and SQL permission validation require deterministic execution. A successful query does not equal business correctness. Trade-offs in this case: evaluate the result set, business metric definitions, and permissions simultaneously.
- Conditions not recommended for adoption
- If metric definitions conflict or there is no permission isolation, govern first; if fixed reports already have stable answers, first evaluate whether a BI dashboard is sufficient. Scenario boundary: when a field does not exist / table dependency is missing, supplement retrieval and retry in a limited way; if it still fails, return the query number and missing information to a data engineer.
- Investment and Ongoing Costs
- The main investment is the semantic layer, question gold standards, permissions, and query protection; subsequent costs include models, query computation, change maintenance, and business review. The first-round interface scope is bounded by recommended data objects such as "production work orders"; the enterprise's actual interfaces and budget require separate investigation.
- Value and evaluation criteria
- Compare data retrieval waiting time, correct answer rate, query cost, and user review time; do not directly treat natural language answer speed as business productivity. In this case, first check the "result and metric definition correctness rate": compare against the result set of reviewed SQL, covering rework in a single column, duplicate JOINs, and cross-day shifts.
- Suggested First Step
- Create work order, operation quality, and shift tables, covering rework, cross-day, and missing data. Prepare at least 30 questions with reference SQL and results. Scope limitation: first use synthetic MES data to reproduce single-plant output, first-pass yield, and work order queries. Read-only database views, do not execute modification statements, and do not connect directly to the production database.
Engineering Implementation Reference
Reference design · Not executedThis section is a reference implementation proposed based on public materials and does not represent the case enterprise's actual internal architecture.
Reference implementationNot yet executedreference- Input Data
- Business terminology, schema and query patterns, Slack requester, partition time range, Athena query permissions, and scan budget.
- System Boundaries
- First validate in a synthetic, de-identified, or authorized isolated environment. First use synthetic MES data to reproduce single-plant output, first-pass yield, and work order queries. Read-only database views, do not execute modification statements, and do not connect directly to the production database.
Reference architecture and normal execution path
- 1
Semantic and schema retrieval: retrieve terminology, table schemas, relationships, and the approved business scope
- 2
SQL validation and budget: Athena EXPLAIN, plus partition, permission, and budget checks
- 3
Dual-confirmation executor: understanding approval and SQL approval are separately bound to state and the original requester
| Key modules | Responsibilities | API / Tool Interaction |
|---|---|---|
| Semantic and schema retrieval | Retrieve terminology, table schemas, relationships, and the approved business scope | Source: Slack + RAG; illustrative: link_schema(intent,domain_version) |
| SQL validation and budget | Athena EXPLAIN, plus partition, permission, and budget checks | Source: EXPLAIN; illustrative: validate_policy(sql,user_scope,max_bytes) |
| Dual-confirmation executor | Understanding approval and SQL approval are separately bound to state and the original requester | Source: Slack Block Kit; illustrative: execute_if_approved(sql_hash,expires_at) |
Failure paths
Stop the affected execution and return missing or conflicting evidence; after re-fetching data and re-reviewing, form a new version.
Supplement retrieval and retry in a limited way; if it still fails, return the query number and missing information to a data engineer.
The queryable scope is determined by server-side permissions; permissions self-declared by the model or user cannot be accepted.
Permission and Security Constraints
Authorize users and system services separately; minimum read permissions, credential isolation, denial logs, and cost budgets are enforced by code. Write operations are bound to the approver, object, version, and idempotency key; approval does not expand permissions.
Conditional Execution Illustration
plan = build_candidate(snapshot, user_scope)
if not policy_allows(plan): reject()
approval = review(hash(plan), versions, expires_at)
if current_versions() != approval.versions: request_new_review()
else: execute_once(approval.plan_hash, idempotency_key)Suggested Acceptance Method
Test ambiguous terminology, incorrect join granularity, unauthorized access, missing partitions, repeated clicks, and SQL modification after approval; report business answer correctness rate, syntax success rate, and scan cost separately. This is an acceptance plan; there are no measured values from this repository.
Research Appendix Complete evidence, metric criteria and research materials
Original disclosure and evidence boundaries
Source verifiedOriginal title: 티오더의 Text2SQL 에이전트 티스푼 구현 사례
Original summary: Enable business personnel to query order, store, and advertising data in natural language, reducing reliance on the technical team for ad hoc data questions.
AWS Korean technical article discloses: torder uses LangGraph to organize the Text2SQL workflow, leverages Bedrock to generate and explain queries, and uses Athena to validate and execute SQL.
Original disclosureSource verifiedfact:1Original location: Section 3: architecture ↗Implement dual human confirmation covering query intent and SQL; RAG retrieval includes table schemas, query patterns, and business terminology.
Original disclosureSource verifiedfact:2Original location: Sections 2, 4, and 5: objectives, workflow, and knowledge retrieval ↗The source describes filling in cross-table dependencies in stages and using Athena EXPLAIN to check SQL; syntax checking cannot be regarded as a guarantee of business metric definition correctness.
Original disclosureSource verifiedfact:3Original location: Sections 5-1 / 5-2: retrieval and SQL workflow ↗The source provides implementation details such as dual human confirmation, staged retrieval, and SQL validation, but does not give independently verifiable manufacturing benefits.
Disclosure BoundariesThe original business belongs to restaurant technology. Manufacturing shifts, rework, operation granularity, and plant permissions need to be redesigned; EXPLAIN cannot prove business result correctness.
Delivery process
AI implementation (FDE not disclosed)The existing source text and research archive are retained; the current materials do not clearly disclose the FDE delivery method for this project.
Project disclosure 3 / 7 items. Vendor methods are labeled separately. Not disclosed means the current verification materials do not explain it.
- Delivery TeamNot disclosed
The verified materials do not state the project's engineering headcount, role configuration, and responsibilities.
- Customer participation and co-creationNot disclosed
The verified materials do not state the specific arrangements for customer participation in design, review, and joint development.
- Project durationNot disclosed
The verified materials do not state the complete development start and end dates or the duration of each delivery phase.
- Data and System IntegrationProject disclosure
Use Bedrock, Athena, and staged retrieval; SQL is first EXPLAINed, then manually confirmed before execution.
Original location: 5-2 SQL 파이프라인 / 5-3 가드레일- Iteration and operationsProject disclosure
Adjust prompts and retrieval based on real operational issues with classification, dates, and missing table schemas; automatic feedback improvement is a follow-up plan.
Original location: 6 시행착오 / 7 마무리- Acceptance and effectiveness evaluationProject disclosure
Classification consistency for the same question repeated 10 times increased from 70% to 90%; this is not full-business SQL accuracy or formal acceptance.
Original location: 6-1 프롬프트 엔지니어링- Handover and Capability TransferNot disclosed
The verified materials do not state engineering training, runbooks, exit, or independent operations handover.
Delivery materials verification date: 2026-10-07
Metrics and Measurement Definitions
Retain original criteria"Source verified" only means the public disclosure can be located; it does not mean business results have undergone independent third-party acceptance. Unknown items remain "not disclosed in the original text."
Quantitative business outcome metrics
Quantitative results not disclosedNot disclosed in the source
Original disclosureSource verifiedmetric:1- Baseline
- Not disclosed in the source
- Comparison Period
- Not disclosed in the source
- Measurement Scope
- Restaurant data query engineering implementation; manufacturing benefits cannot be extrapolated
- Limitations
- Samples, measurement methods, and complete controls are not disclosed; source disclosure is not equivalent to third-party independent acceptance.
Research Verification Materials
Engineering Verification Status
Type, scope, and execution are recorded separatelyVerification has no automatic progression; passing limited synthetic samples does not prove the model, the complete system, or customer production acceptance. Public business outcomes are shown only according to the original evidence.
This section is an engineering reference design, and there is no end-to-end execution record in this library yet.
Reference design · Not yet executed
- Verification scope
- First validate in a synthetic, de-identified, or authorized isolated environment. First use synthetic MES data to reproduce single-plant output, first-pass yield, and work order queries. Read-only database views, do not execute modification statements, and do not connect directly to the production database.
- Input Data
- Business terminology, schema and query patterns, Slack requester, partition time range, Athena query permissions, and scan budget.
- Expected output
- Test ambiguous terminology, incorrect join granularity, unauthorized access, missing partitions, repeated clicks, and SQL modification after approval; report business answer correctness rate, syntax success rate, and scan cost separately. This is an acceptance plan; there are no measured values from this repository.
- Actual output
- Not yet executed, no actual output
- Execution Time
- Not yet executed; collection time is not used as a substitute
- Limitations and failure notes
- This section is an engineering reference design, and there is no end-to-end execution record in this library yet.
Test Plan · Not yet executed
- Verification scope
- First use synthetic MES data to reproduce single-plant output, first-pass yield, and work order queries. Read-only database views, do not execute modification statements, and do not connect directly to the production database.
- Input Data
- Synthetic, public, or authorized data; specific experimental inputs are still to be prepared.
- Expected output
- The reference results were manually reviewed; they include counterexamples that would cause duplicate counting.;Modifying approved SQL requires re-approval; cross-plant queries and write statements are blocked.;Display error classification and applicable scope; do not infer production availability from correct answers in demonstrations.
- Actual output
- Not yet executed, no actual output
- Execution Time
- Not yet executed; collection time is not used as a substitute
- Limitations and failure notes
- Phased reproduction and evaluation are planned and cannot be used to prove that an actual system is already running.
Phased reproduction path
The complete solution has not yet been executedUse synthetic, public or authorized data. The following is a follow-up plan; if there is a rule check above, it only proves the samples it explicitly lists and does not mean complete reproduction has been completed.
- 1
Construct a manufacturing data Q&A baseline
Create work order, operation quality, and shift tables, covering rework, cross-day, and missing data. Prepare at least 30 questions with reference SQL and results.
Planned deliverables:Reproducible dataset, metric dictionary, reference queries, and expected results.
Suggested acceptance conditions:The reference results were manually reviewed; they include counterexamples that would cause duplicate counting.
- 2
Retrieval and dual confirmation
Implement intent clarification, knowledge retrieval, SQL validation, and approval; queries are executed through a read-only agent, and the approved version is recorded.
Planned deliverables:Process state diagram, query trace, read-only execution interface.
Suggested acceptance conditions:Modifying approved SQL requires re-approval; cross-plant queries and write statements are blocked.
- 3
Regression and business demonstration
Compare template queries, direct generation, and retrieval-augmented approaches on the same question set, and demonstrate continuous follow-up questions and failure handling.
Planned deliverables:Result correctness rate report, error examples, query cost, and time records.
Suggested acceptance conditions:Display error classification and applicable scope; do not infer production availability from correct answers in demonstrations.
Evaluation and Failure Handling
Proposed Solution to Be VerifiedThe evaluation targets are recommended thresholds and need to be adjusted based on risk and baseline; there are currently no measured results.
| Metrics | Measurement Method | Suggested Judgment Conditions |
|---|---|---|
| Result and metric definition correctness rate | Compare against the result set of reviewed SQL, covering rework in a single column, duplicate JOINs, and cross-day shifts. | Expand scope only after all key metric definition tests pass; report the total number of questions, number of failures, and reasons. |
| Unauthorized access and modification statement interception | Attempt cross-plant access, DML, DDL, nested bypasses, and prompt induction. | In acceptance, unauthorized execution and writes are both zero, and failed requests leave audit records. |
| Scan volume and response time | Record bytes scanned per query, cost estimates, and end-to-end P95, including approval waiting. | Set a budget cap based on data volume; when exceeded, first prompt to narrow the query scope. |
| Consistency of continuous follow-up questions | First ask about yield by shift, then change product, date, or plant, and verify that the context updates. | New conditions must not mistakenly use old filters; ambiguous follow-up questions must be clarified again. |
Questions to confirm in the next round
- Which department is responsible for manufacturing metric definitions, and how are old queries invalidated after changes?
- How is the approver's intent confirmation bound to the actually executed SQL version?
- Could production data refresh delays and shift time zones make "yesterday" results misleading?
Verification Records and Items to Be Confirmed
2026-10-09Lightweight content completeness review: source definitions, important values, subjects, phases, components, and prototype/production boundaries.
Key assertions verified against the source
- Review percentages/orders of magnitude, currency, time windows, enterprises and teams, project phase, technical components, and prototype/production boundaries; no independent acceptance of internal enterprise implementation or business benefits was performed.
- Key metric definition focus in this case: the original business belongs to restaurant technology. Manufacturing shifts, rework, operation granularity, and plant permissions need to be redesigned; EXPLAIN cannot prove business result correctness.
View all assertions · 6 items
Original disclosure · Source verified · torder:fact:1
Complete assertion: AWS Korean technical article discloses: torder uses LangGraph to organize the Text2SQL workflow, leverages Bedrock to generate and explain queries, and uses Athena to validate and execute SQL.
- Verification method
- Original materials verification
- Last Verified
- 2026-10-09
- Applicable boundaries
- Source disclosures have been recorded; this lightweight review is not equivalent to item-by-item re-acceptance. Business benefits are self-reported by the source and have not undergone third-party independent acceptance.
- Related cases
- torder: Text2SQL with dual approval
Original disclosure · Source verified · torder:fact:2
Complete assertion: Implement dual human confirmation covering query intent and SQL; RAG retrieval includes table schemas, query patterns, and business terminology.
- Verification method
- Original materials verification
- Last Verified
- 2026-10-09
- Applicable boundaries
- Source disclosures have been recorded; this lightweight review is not equivalent to item-by-item re-acceptance. Business benefits are self-reported by the source and have not undergone third-party independent acceptance.
- Related cases
- torder: Text2SQL with dual approval
Original disclosure · Source verified · torder:fact:3
Complete assertion: The source describes filling in cross-table dependencies in stages and using Athena EXPLAIN to check SQL; syntax checking cannot be regarded as a guarantee of business metric definition correctness.
- Verification method
- Original materials verification
- Last Verified
- 2026-10-09
- Applicable boundaries
- Source disclosures have been recorded; this lightweight review is not equivalent to item-by-item re-acceptance. Business benefits are self-reported by the source and have not undergone third-party independent acceptance.
- Related cases
- torder: Text2SQL with dual approval
Original disclosure · Source verified · torder:metric:1
Complete assertion: Quantitative business outcome metrics: not disclosed in the source
- Verification method
- Original materials verification
- Last Verified
- 2026-10-09
- Applicable boundaries
- Samples, measurement methods, and complete controls are not disclosed; source disclosure is not equivalent to third-party independent acceptance. Restaurant data query engineering implementation; manufacturing benefits cannot be extrapolated
- Related cases
- torder: Text2SQL with dual approval
Engineering Projection · Not yet executed · torder:insight
Complete assertion: Dual approval separately confirms business semantics and SQL execution risk
- Verification method
- No experimental validation yet
- Last Verified
- Not yet verified or executed
- Applicable boundaries
- Engineering inference by this repository; based on public disclosures and existing research, it does not represent the customer's internal plan or executed experiments.
- Related cases
- torder: Text2SQL with dual approval
Reference implementation · Not yet executed · torder:reference
Complete assertion: Engineering implementation reference: dual approval separately confirms business semantics and SQL execution risk
- Verification method
- No experimental validation yet
- Last Verified
- Not yet verified or executed
- Applicable boundaries
- The reference interfaces are all illustrative, are not connected to the enterprise's real systems, and no complete reproduction experiment has been executed; existing synthetic experiment records are retained separately.
- Related cases
- torder: Text2SQL with dual approval
Review record: torder:audit:20261009 · Full-library review records
Original research judgment and attribution
This is an engineering template that can be migrated to manufacturing data Q&A; its value lies in business metric definition retrieval, SQL validation, and two human confirmations. During migration, work orders, batches, shifts, and plant permissions should be addressed first, rather than directly replacing a few table names. The original case business belongs to restaurant technology.
Research compilation and solution analysis: Zuren Zhao · AI-assisted compilation. Original case delivery belongs to the original enterprises and service providers.