Take a query-history definition draft's tables and columns from the query log
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with group_sql in server/knowledge/store/query_history_remote.py, then trace how query-history data reaches the prompt and rests_on through server/memory/app/definition_drafts.py and server/memory/domain/definition_drafts.py. Add the acceptance fixture in tests/integration/test_query_history_drafts.py and check the query-log arrays, capped lists, gap drafts, and one model call per draft.
Written by the indexing model from the issue text.
Description
Company
ClickHouse
Component
Knowledge (documents)
Use case
A definition drafted from query history records the tables and columns it rests on in rests_on. Today the model writes both lists. The draft prompt asks for tables and columns, and the reply is stored after a size check only (server/memory/app/definition_drafts.py, server/memory/domain/definition_drafts.py). The source already knows the answer: system.query_log holds the tables and columns each query read, and the query-history read does not select them (group_sql in server/knowledge/store/query_history_remote.py).
An admin reviewing the draft, or a later check of the definition against its source, reads a list that can name a table the query never touched or omit one it did. rests_on holds the source's normalized SQL beside the model's two lists and does not mark which is which; only the documentation says so (docs/architecture/definition-drafts.md).
Describe the solution you'd like
Read the lists from the source and stop asking the model for them. This is a proposal; nothing is implemented or measured.
group_sqlalso selects thetablesandcolumnsarrays of the query whose text it keeps, each cut to the draft's existing list limits. A cut list is reported as capped, not passed off as complete. The registration probe runs the same statement, so it also verifies that the credential can read the two arrays.- For a query-history draft,
rests_on.tablesandrests_on.columnscome from that read.rests_onrecords where the lists came from, so a reader can tell a source-read list from one written before this change. - The prompt and
DefinitionDraftdroptablesandcolumns. The model still returns the term, aliases and body. - A draft from a knowledge gap has no SQL and no source to read, so it carries no table or column list.
- The read stays inside the registration's database allowlist, which the existing filter on the log's
databasesarray already applies. The lists keep the visibilityrests_onhas today. - The change adds no model call, no table and no statement on the source beyond the existing bounded query-log read.
Acceptance fixture, added to tests/integration/test_query_history_drafts.py:
- A query group over one table yields a draft whose
rests_onlists equal the log's arrays, whatever the model returns. - The model input and the expected reply contain no table or column list.
- A group whose arrays exceed the limits yields cut lists marked capped.
- A query through a view records what the log records for it.
- A gap draft has no lists.
- The model-call count per draft stays at one.
Evidence still needed before this is called a gain:
- A read-only count, on a deployment that has query-history drafts, of the share whose model-written lists differ from the log's arrays for the same query.
- Whether the drafted term, aliases and body change when the prompt stops asking for the two lists. This needs a paired run on fixed query groups, and a paid run only on request.
- What the log's arrays contain for views,
SELECT *and joins on the supported server versions, confirmed in the fixture.
Describe alternatives you've considered
- Parse the normalized SQL in the server. The server imports no SQL parser;
sqlglotis in the extractor's dependency group only. A parser also cannot resolve a view orSELECT *the way the source does. - Keep the model's lists and verify them against
system.columns. That adds a metadata read on the data tables, and registration verifies the query-log read only, not that the credential can see those tables' columns. - Leave it as documented. The lists then stay unusable as evidence for any later check.
Where the need comes from
An AI tool suggested this feature
Additional context
Found by source review; no draft was generated and no source was queried.
Related: #1176 checks maintained guidance against a registered tracker source, with objects a maintainer declares. This change is separate and smaller. It gives query-history definitions a source-read list that a later extension of that check could use. Part of the roadmap in #1232.
- Dominant language
- Python
- Stars
- 263
- Forks
- 47
- Avg merge
- 14h 21m
- Merged PRs (30d)
- 873
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ClickHouse/loom
-
Difficulty 1/5 1-3 hours Newbie friendliness 76/100
ClickHouse/loom#2014 ·
Maintainers usually reply within 1 day
-
Options of loom period-digest, reextract, reconcile-status and demote-activity-narration print no help textPossibly taken @VanshajPoonia claimed this today. Openbug good first issue help wanted up-for-grabs
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/loom#1988 · 1 comment ·
Maintainers usually reply within 1 day
-
A compiler-tier checkout fetch from a shallow mirror never records its headPossibly taken @KaloyanNaumov claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
ClickHouse/loom#2016 ·
Maintainers usually reply within 1 day
-
Delta workers fetch the compiler-tier checkout under a hard-coded 600 s limitPossibly taken @KaloyanNaumov claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 35/100
ClickHouse/loom#2012 ·
Maintainers usually reply within 1 day
-
loom participant retire cannot retire an orphaned participant after container replacement or host rebootPossibly taken @l0K1ngg claimed this today. Openbug help wanted up-for-grabs
Difficulty 4/5 3-5 days Newbie friendliness 48/100
ClickHouse/loom#2007 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
DMB documentation good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ubuntu/ubuntu-project-docs#921 ·
Maintainers usually reply within 1 day
-
⏳ Pending feedback 🐛 Bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
jumpserver/jumpserver#18282 · 1 comment ·
Maintainers usually reply within 1 day
-
accepted
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
future-agi/future-agi#5274 ·
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
GenericMappingTools/pygmt#5014 · 1 comment ·
Maintainers usually reply within 1 day