SnowPro Specialty: Gen AI Question 69
Single answerStructured/text-to-SQL use casesA retail analytics team wants business users to ask questions in natural language, such as "Which product category had the highest revenue in the Northeast last quarter?" The team plans to use a large language model to generate SQL against Snowflake tables. Their top concerns are preventing incorrect joins, reducing hallucinated column names, and ensuring generated SQL stays aligned with the approved business definitions. Which approach is the BEST fit for this structured text-to-SQL use case?
- A
Provide the model with a curated semantic layer or governed schema context that defines approved tables, relationships, and business metrics, and constrain SQL generation to that context
- B
Allow the model to infer the database structure directly from a few example prompts, because examples are usually enough to eliminate schema errors in SQL generation
- C
Convert the structured warehouse data into unstructured text documents and use only semantic search over those documents instead of generating SQL
- D
Give the model full access to all schemas in the Snowflake account so it can choose the most relevant tables dynamically at runtime
Show answer and explanation
Correct answer: A
Explanation
For structured/text-to-SQL workloads, the strongest pattern is to ground the model with governed metadata and a constrained schema domain. The model should not be expected to discover correct joins and business definitions from prompts alone. Instead, teams should provide explicit context such as table descriptions, column meanings, approved relationships, and metric definitions, then restrict generation to those vetted objects. This follows common best practices for enterprise text-to-SQL systems: reduce the schema search space, align outputs to semantic definitions, and use the database engine for execution over structured data rather than replacing it with document retrieval. In Snowflake-oriented GenAI designs, this approach supports higher accuracy, better governance, and more trustworthy SQL generation for analytics use cases.
- A. Correct.
Correct. In text-to-SQL scenarios, the most reliable approach is to ground the model with governed, structured context: approved tables, columns, joins, and metric definitions. This reduces hallucinated fields, prevents invalid join paths, and keeps generated SQL aligned with business meaning. In practice, narrowing the available schema and supplying metadata such as descriptions, relationships, and metric definitions is a key best practice for structured use cases.
- B. Incorrect.
Incorrect. Few-shot examples can help formatting and pattern learning, but they do not reliably replace explicit schema grounding. A model may still invent columns, misunderstand join logic, or apply inconsistent business definitions if it does not have authoritative schema context.
- C. Incorrect.
Incorrect. Semantic search over documents is useful for unstructured retrieval tasks, but it is not the best solution when users need precise, aggregatable answers from structured warehouse data. Converting structured data into text also loses the advantages of SQL execution, governed joins, and deterministic aggregation.
- D. Incorrect.
Incorrect. Broadening access to every schema increases ambiguity and risk. It makes hallucinations and incorrect table selection more likely, and it can create governance and security concerns. Best practice is to minimize the schema surface area and expose only the approved domain context needed for the use case.