feat(datafabric): add choice-set awareness to NL-to-SQL pipeline - #1057
Draft
UIPath-Harshit wants to merge 3 commits into
Draft
feat(datafabric): add choice-set awareness to NL-to-SQL pipeline#1057UIPath-Harshit wants to merge 3 commits into
UIPath-Harshit wants to merge 3 commits into
Conversation
The NL-to-SQL pipeline had zero choice-set awareness — choice-set fields were rendered as raw SQL types (int/nvarchar) with no value metadata, no label-to-NumberId mapping, and no filtering guidance. This caused incorrect SQL generation (e.g. WHERE Priority = 4 instead of Priority = 0 for "Critical") and unintelligible results (raw NumberIds instead of labels). Changes: - models.py: Add ChoiceSetValueSchema, choiceset_id/choiceset_values to FieldSchema, is_choice_set property, fix is_numeric to return False for CS fields, add shared_choicesets/choiceset_label_maps to SQLContext - datafabric_prompt_builder.py: Fetch choice-set values via SDK during schema resolution, bridge choiceSetId alias mismatch via entity GET, render value mappings inline in schema table and as dedicated section, emit cross-entity shared choice-set join hints - datafabric_subgraph.py: Enrich query results with _label suffix columns for choice-set NumberIds, pass label maps through QueryExecutor - datafabric_prompts.py: Add Rule 12 for choice-set integer NumberId usage - prompts/v1.py: Add CHOICE-SET FIELDS guidance in VALUE RESOLUTION step, update EMPTY_RESULT error recovery to reference CS mappings Verified: 15/15 tests pass (8 deterministic + 7 live NL-to-SQL) covering all 10 identified choice-set gaps across SDK, prompt, model, and agent layers. 117 existing unit tests pass with zero regressions. Ref: DS-8647 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
The NL-to-SQL pipeline had zero choice-set awareness. Choice-set fields (CHOICE_SET_SINGLE / CHOICE_SET_MULTIPLE) were rendered as raw SQL types (
int/nvarchar) with:This caused incorrect SQL generation (e.g.
WHERE Priority = 4instead ofPriority = 0for "Critical") and unintelligible results ("priority 0" instead of "Critical").Changes
models.pyChoiceSetValueSchema,choiceset_id/choiceset_valuesonFieldSchema,is_choice_setproperty,is_numericreturns False for CS fields,shared_choicesets/choiceset_label_mapsonSQLContextdatafabric_prompt_builder.pychoiceSetIdalias mismatch via entity GET, render value mappings inline + dedicated section, emit cross-entity shared CS join hintsdatafabric_subgraph.pyQueryExecutorenriches results with_labelsuffix columns for CS NumberIdsdatafabric_prompts.pyprompts/v1.pyTest plan
10 Gaps Addressed
Priority = 4(wrong)Priority = 0(correct)is_choice_set, values, mapping_strCritical=0, High=1...inlinePriority_label: 'Critical'🤖 Generated with Claude Code