Area: Observability Issues
Sub-Area: AI Context Generation / Query Corpus
Applies to: Cloud
Issue
A Context Generation job scoped to a domain finishes, but it produces no documents from query history. The run report shows queries_read=0, anchors_generated=0 and query_corpus_empty=true. The GraphQL listQueries API returns many query entities for the same datasets.
The run log shows no skipped queries:
ElasticSearchQuerySource: yielded=0, errors=0, skips={}
You Might Be Asking
- Why does
listQueriesreturn hundreds of queries while Context Generation reads zero? - Why does the run log show
skips={}when queries exist? - Why does Context Generation work for one domain but not for another?
- How do I check whether a query has usage features?
- Which version fixes this?
Cause
On DataHub Cloud v2.3.5 and earlier, Context Generation finds its queries with a search that requests the queryUsageFeatures aspect of each query. The search leaves out every query that does not have that aspect. These queries never reach the skip counter, so the log shows skips={}.
A scheduled DataHub usage reporting job computes queryUsageFeatures. It reads the per query usage statistics (queryUsageStatistics) that your warehouse ingestion writes. This means:
- A query that was ingested after the last usage reporting run has no usage features yet.
- A query that has no
queryUsageStatisticsat all never gets usage features. On v2.3.5 and earlier, Context Generation never reads it.
listQueries does not filter on usage features, so it counts every query entity in scope. That is why its count does not match queries_read.
When one domain works and another does not, the queries in the working domain already have usage features, and the queries in the failing domain do not.
DataHub Cloud v2.3.6 and v2.4.0 and later fix this. Context Generation reads every in-scope query. It reads a query without usage features as a query with zero executions and no users. On these versions the run log line includes a count of those queries, for example ElasticSearchQuerySource: yielded=250 (40 without usage), errors=0, skips={}. If your log line has no without usage count, your instance runs an affected version.
Solution
- Check whether the in-scope queries have usage features. Run this query with the DataHub GraphQL API for a sample of query URNs:
query CheckQueryUsageFeatures {
entity(urn: "urn:li:query:<your-query-id>") {
... on QueryEntity {
usageFeatures {
queryCountLast30Days
lastExecutedAt
topUsersLast30Days {
urn
}
}
}
}
}
If usageFeatures is null, the usage reporting job has not computed usage features for that query. On v2.3.5 and earlier, Context Generation does not read it.
-
Upgrade to DataHub Cloud v2.3.6, or v2.4.0 or later. This is the fix. After the upgrade, Context Generation reads queries with and without usage features. Contact DataHub Support to schedule the upgrade.
-
Until you upgrade, re-run the job after the usage reporting job has computed usage features for the in-scope queries. Use step 1 to confirm that
usageFeaturesis populated. Then open Settings > Context and click the run (play) button on the job's row. After the run, confirm thatqueries_readis greater than zero in the run report. This does not help for queries that have noqueryUsageStatistics. Only the upgrade makes Context Generation read those. -
To give queries usage features, make sure your warehouse ingestion writes query usage statistics. The Context Generation guide lists the recipe settings for each supported platform under Reference recipes.
On v2.4.0 and later, a job also reads only queries whose last recorded run falls inside the job's query history window (90 days by default). If a run on a fixed version still reads zero queries, check that window and the FAQ in the Context Generation guide.