feat: make table sample data in SQL prompts configurable - #1359
Closed
moonbrigt wants to merge 1 commit into
Closed
Conversation
Add a default-on TABLE_SAMPLE_DATA_ENABLED setting. When disabled, skip automatic sample queries and omit sample values from SQL prompt templates. Preserve schema context and explicit query/preview behavior. Add isolated regression tests and document configuration and limitations. Refs #1291
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.
When generating SQL, SQLBot currently fetches up to three sample rows from selected tables and includes them in the model context. This adds a
TABLE_SAMPLE_DATA_ENABLEDsetting so deployments can disable that automatic sample context.Closes #1291.
Changes
trueto preserve existing behavior and the three-row sample limit.false, return from automatic sampling before reading table metadata or sample rows, and omit sample values from SQL prompt rendering even whensample_datawas populated earlier. Copy the template before changing it so the cached template is preserved.This setting only controls automatic table samples in SQL-generation context. User messages, field comments, SQL examples, query results, and analysis prompts can still contain business data; this is not a global data-loss-prevention switch.
Validation
python -m pytest -q tests/test_table_sample_data.py), with pytest and Pydantic dependencies in an isolated uv environment.git diff HEAD^ HEAD --check.The regression tests execute actual source function definitions with dependency doubles and use the real Pydantic settings loader. They cover configuration parsing, skipped sampling, existing sampling behavior, sample exclusion, template cache preservation, and unaffected schema/query/preview behavior. They do not validate full application imports or integration with external services.
Submitting as a draft because full application startup, real database/model-provider integration, MCP/embedded entry points, and full dependency integration have not been tested. Lint and type checks have not been run. CI status is not claimed as passed.