Area: API Issues
Sub-Area: GraphQL Search and Filtering
Applies to: OSS + Cloud
Issue
You filter datasets by a container URN in a GraphQL query and get no results, even though datasets exist under that container. This usually happens with a database-level container (for example a Snowflake database) that holds schema containers. You may also try to filter by container name and get nothing back.
You Might Be Asking
- Why doesn't filtering by a database-level container URN return datasets from child schemas?
- Can I filter datasets by container name instead of the full URN?
- Why do filters on a schema container work but filters on a database container don't?
- How can I search for datasets across an entire container hierarchy?
- Are all GraphQL filter fields URN-based?
Cause
- A dataset stores one parent container URN, its immediate parent (the
containeraspect). See the Container entity documentation. - The Snowflake source adds each table to its schema container. The schema container sits under the database container. So a table stores the schema URN, not the database URN.
- When you don't set
condition, the filter uses equality. A database URN matches nothing, because no dataset stores it as its direct parent. - The
containerfilter field is URN-typed. You must pass container URNs, not names.
Solution
Include nested containers with DESCENDANTS_INCL
Set condition: DESCENDANTS_INCL on the container filter. This operator matches the given URN and its nested children. Put the filter inside orFilters as and: [...]. See the search guide for the orFilters format.
query {
searchAcrossEntities(
input: {
types: [DATASET],
query: "*",
orFilters: [{
and: [{
field: "container",
values: ["urn:li:container:<your-database-container-urn>"],
condition: DESCENDANTS_INCL
}]
}]
}
) {
total
searchResults {
entity {
urn
type
}
}
}
}
Check large databases
On DataHub Cloud v2.4.4, container expansion is on by default and has a limit of 100. If a database has a very large number of child containers and total is lower than you expect, filter on the schema container URNs directly with the default equality condition. You can also contact DataHub Support about the limit.
Self-hosted: the limit is set by SEARCH_SERVICE_FILTER_CONTAINER_EXPANSION_LIMIT, and SEARCH_SERVICE_FILTER_CONTAINER_EXPANSION_ENABLED turns expansion on or off.
Filter by container name
Container filters need full URNs. Use two steps.
- Search for the container to get its URN.
CONTAINERis a valid entity type. See the GraphQL query reference.
query {
searchAcrossEntities(
input: {
types: [CONTAINER],
query: "YOUR_CONTAINER_NAME"
}
) {
searchResults {
entity {
urn
type
}
}
}
}
- Use the returned URN in the dataset filter from the previous section.
entity is the Entity interface, which has only urn, type and relationships. To select other fields, use an inline fragment such as ... on Container { ... }.
Not every filter field is a URN
- URN-typed fields include
container,tags,fieldTagsanddomains. - The
originfield (shown as Environment) holds a plain FabricType value, not a URN. - The Sub Type filter field is a plain keyword field.
Related Documentation
- Container Entity Documentation
- GraphQL API Getting Started
- Search and Discovery Guide
- GraphQL query reference
Tags: graphql, container, filtering, hierarchy, api, search, descendants, urn, snowflake