Repository navigation
feat(agent-context): return OKF document properties and add okf_* filter aliases - #21876
shirshanka wants to merge 6 commits into
Conversation
search_documents and get_entities return okfProperties for documents with OKF frontmatter, with the frontmatter parsed and capped in size. get_entities reads it with its own query, since GetEntity's Document arm is a NEWER_GMS block. The shared filter parser gains okf_type, okf_status, okf_bundle and okf_id (concept or declared id), matched with IEQUAL, plus okf_stale_after for comparisons. FILTER_DOCS and the tool descriptions document them, searching by OKF id, and that type means entity type.
PR SummaryOverview Responses: Filters: The shared Reviewed by Cursor Bugbot for commit f315a3b. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Smart test selectionpytest smoke testsMode: active. Only the selection below runs for the pytest smoke tests on this PR (applied:
Medium confidence: a wrong tag means tests are skipped, so check the tags above against what this PR touches. Selected scopes (47 files or classes, 212 tests)
Add the commit |
There was a problem hiding this comment.
3 issues found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="datahub-agent-context/src/datahub_agent_context/mcp_tools/helpers.py">
<violation number="1" location="datahub-agent-context/src/datahub_agent_context/mcp_tools/helpers.py:32">
P2: The 4000-character cap applies per document only. `search_documents` can return 50 documents, so one page can carry about 200k characters of frontmatter (roughly 50k tokens) with no response-level budget. Apply a running token or character budget on the documents search path, as `_select_results_within_budget` does for lineage and incidents.</violation>
</file>
<file name="metadata-ingestion/src/datahub/cli/search_filter_parser.py">
<violation number="1" location="metadata-ingestion/src/datahub/cli/search_filter_parser.py:509">
P2: Comparison operators on `okf_type`, `okf_status`, `okf_bundle`, and `okf_id` send the raw alias name to the backend, which matches nothing. Either map these aliases in the comparison branch or reject comparisons on non-numeric OKF fields with a clear `ValueError`.</violation>
</file>
<file name="datahub-agent-context/tests/unit/mcp_tools/test_search_filter_parser.py">
<violation number="1" location="datahub-agent-context/tests/unit/mcp_tools/test_search_filter_parser.py:850">
P2: Custom agent: **Enforce Pragmatic Test Coverage**
`okf_stale_after IS NULL`, `okf_stale_after >`, and `okf_id IS NOT NULL` are new parser branches that these tests don't exercise — this file is the only coverage for the OKF aliases, and the PR description promises `>`/`<`/`IS NULL` on all of them. Extend the OKF tests with assertions for `okf_stale_after > x` (GREATER_THAN), `okf_stale_after IS NULL` (NOT EXISTS okfStaleAfter), and `okf_id IS NOT NULL` (OR of EXISTS on okfConceptId/okfDeclaredId).</violation>
</file>
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack
View guided diff | Turn on auto-fix | Re-trigger cubic
|
|
||
| # Max size of an OKF document's frontmatter (as JSON) in tool responses. Above it the | ||
| # frontmatter is left out and the typed okfProperties fields remain. | ||
| OKF_FRONTMATTER_CHAR_LIMIT = int(os.getenv("OKF_FRONTMATTER_CHAR_LIMIT", "4000")) |
There was a problem hiding this comment.
P2: The 4000-character cap applies per document only. search_documents can return 50 documents, so one page can carry about 200k characters of frontmatter (roughly 50k tokens) with no response-level budget. Apply a running token or character budget on the documents search path, as _select_results_within_budget does for lineage and incidents.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At datahub-agent-context/src/datahub_agent_context/mcp_tools/helpers.py, line 32:
<comment>The 4000-character cap applies per document only. `search_documents` can return 50 documents, so one page can carry about 200k characters of frontmatter (roughly 50k tokens) with no response-level budget. Apply a running token or character budget on the documents search path, as `_select_results_within_budget` does for lineage and incidents.</comment>
<file context>
@@ -26,6 +27,10 @@
+# Max size of an OKF document's frontmatter (as JSON) in tool responses. Above it the
+# frontmatter is left out and the typed okfProperties fields remain.
+OKF_FRONTMATTER_CHAR_LIMIT = int(os.getenv("OKF_FRONTMATTER_CHAR_LIMIT", "4000"))
+
</file context>
| value = self._expect_condition_value().value | ||
| return F.custom_filter(field, self._COMPARISON_OPS[op_token.type], [value]) | ||
| return F.custom_filter( | ||
| _resolve_range_field(field), |
There was a problem hiding this comment.
P2: Comparison operators on okf_type, okf_status, okf_bundle, and okf_id send the raw alias name to the backend, which matches nothing. Either map these aliases in the comparison branch or reject comparisons on non-numeric OKF fields with a clear ValueError.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At metadata-ingestion/src/datahub/cli/search_filter_parser.py, line 509:
<comment>Comparison operators on `okf_type`, `okf_status`, `okf_bundle`, and `okf_id` send the raw alias name to the backend, which matches nothing. Either map these aliases in the comparison branch or reject comparisons on non-numeric OKF fields with a clear `ValueError`.</comment>
<file context>
@@ -481,7 +505,11 @@ def _parse_condition(self) -> Filter:
value = self._expect_condition_value().value
- return F.custom_filter(field, self._COMPARISON_OPS[op_token.type], [value])
+ return F.custom_filter(
+ _resolve_range_field(field),
+ self._COMPARISON_OPS[op_token.type],
+ [value],
</file context>
| ) | ||
|
|
||
|
|
||
| def test_okf_stale_after_supports_comparisons_and_null_checks(): |
There was a problem hiding this comment.
P2: Custom agent: Enforce Pragmatic Test Coverage
okf_stale_after IS NULL, okf_stale_after >, and okf_id IS NOT NULL are new parser branches that these tests don't exercise — this file is the only coverage for the OKF aliases, and the PR description promises >/</IS NULL on all of them. Extend the OKF tests with assertions for okf_stale_after > x (GREATER_THAN), okf_stale_after IS NULL (NOT EXISTS okfStaleAfter), and okf_id IS NOT NULL (OR of EXISTS on okfConceptId/okfDeclaredId).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At datahub-agent-context/tests/unit/mcp_tools/test_search_filter_parser.py, line 850:
<comment>`okf_stale_after IS NULL`, `okf_stale_after >`, and `okf_id IS NOT NULL` are new parser branches that these tests don't exercise — this file is the only coverage for the OKF aliases, and the PR description promises `>`/`<`/`IS NULL` on all of them. Extend the OKF tests with assertions for `okf_stale_after > x` (GREATER_THAN), `okf_stale_after IS NULL` (NOT EXISTS okfStaleAfter), and `okf_id IS NOT NULL` (OR of EXISTS on okfConceptId/okfDeclaredId).</comment>
<file context>
@@ -804,3 +804,57 @@ def test_boolean_filter_combined_with_and():
+ )
+
+
+def test_okf_stale_after_supports_comparisons_and_null_checks():
+ assert parse_filter_string("okf_stale_after < 1767225600000") == F.custom_filter(
+ "okfStaleAfter", "LESS_THAN", ["1767225600000"]
</file context>
There was a problem hiding this comment.
4 issues found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="datahub-agent-context/src/datahub_agent_context/mcp_tools/helpers.py">
<violation number="1" location="datahub-agent-context/src/datahub_agent_context/mcp_tools/helpers.py:261">
P2: Custom agent: **Enforce i18n for User-Facing Strings**
This English message is returned as `frontmatterOmitted` in the tool response, so it is user-facing text rather than a log or technical identifier. Wrap it in the project’s translation mechanism.</violation>
</file>
<file name="datahub-agent-context/tests/unit/mcp_tools/test_okf_documents.py">
<violation number="1" location="datahub-agent-context/tests/unit/mcp_tools/test_okf_documents.py:34">
P2: Custom agent: **Enforce Strict Maintainability Standards**
`test_gql_selects_okf_properties` extracts the `okfProperties` block by counting braces and then asserts on `line.split()[0]` of every line, so a blank line or `#` comment added inside the block raises a bare `IndexError`/corrupts the depth count, and fields placed on a shared line are silently dropped from the assertion. Filter out blank and comment lines before taking the first token, and fail with a clear message when `okfProperties {` is missing.</violation>
<violation number="2" location="datahub-agent-context/tests/unit/mcp_tools/test_okf_documents.py:107">
P2: Custom agent: **Enforce Pragmatic Test Coverage**
No test covers a document whose `GetDocumentOkfProperties` lookup succeeds but returns no `okfProperties` — the common non-OKF document case the PR description calls out. The existing tests cover the OKF-present and lookup-raises paths, but not the branch where `entities.py`'s `if okf_result and okf_result.get("okfProperties")` guard is not taken. Add a test asserting `"okfProperties" not in result` after a successful-but-empty lookup, mirroring the failure test with a second response of `{"entity": {"urn": urn, "okfProperties": None}}`.</violation>
</file>
<file name="datahub-agent-context/tests/unit/mcp_tools/test_search_filter_parser.py">
<violation number="1" location="datahub-agent-context/tests/unit/mcp_tools/test_search_filter_parser.py:835">
P2: Custom agent: **Enforce Pragmatic Test Coverage**
The `_negate_filter` change makes `NOT (a = x OR b = y)` over plain custom fields compile to `a != x AND b != y` instead of raising, but the new tests exercise this De Morgan branch only through the `okf_id` alias. Add a direct test for the general path, e.g. in metadata-ingestion/tests/unit/cli/test_search_filter_parser.py (untouched by this PR), asserting `parse_filter_string("NOT (a = x OR b = y)") == F.and_(F.not_(F.custom_filter("a", "EQUAL", ["x"])), F.not_(F.custom_filter("b", "EQUAL", ["y"])))` and the same via `!=`; otherwise a regression in this documented side effect ships silently.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| if len(frontmatter) > OKF_FRONTMATTER_CHAR_LIMIT: | ||
| del value["frontmatter"] | ||
| value["frontmatterOmitted"] = ( | ||
| f"Frontmatter is {len(frontmatter)} characters, over the " |
There was a problem hiding this comment.
P2: Custom agent: Enforce i18n for User-Facing Strings
This English message is returned as frontmatterOmitted in the tool response, so it is user-facing text rather than a log or technical identifier. Wrap it in the project’s translation mechanism.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At datahub-agent-context/src/datahub_agent_context/mcp_tools/helpers.py, line 261:
<comment>This English message is returned as `frontmatterOmitted` in the tool response, so it is user-facing text rather than a log or technical identifier. Wrap it in the project’s translation mechanism.</comment>
<file context>
@@ -234,6 +239,39 @@ def _select_results_within_budget(
+ if len(frontmatter) > OKF_FRONTMATTER_CHAR_LIMIT:
+ del value["frontmatter"]
+ value["frontmatterOmitted"] = (
+ f"Frontmatter is {len(frontmatter)} characters, over the "
+ f"{OKF_FRONTMATTER_CHAR_LIMIT}-character limit. The fields "
+ f"above hold its main OKF keys."
</file context>
| lines = (GQL_DIR / gql_file).read_text().splitlines() | ||
| first = next(i for i, line in enumerate(lines) if "okfProperties {" in line) | ||
| block, depth = [], 0 | ||
| for line in lines[first:]: | ||
| block.append(line) | ||
| depth += line.count("{") - line.count("}") | ||
| if depth == 0: | ||
| break |
There was a problem hiding this comment.
P2: Custom agent: Enforce Strict Maintainability Standards
test_gql_selects_okf_properties extracts the okfProperties block by counting braces and then asserts on line.split()[0] of every line, so a blank line or # comment added inside the block raises a bare IndexError/corrupts the depth count, and fields placed on a shared line are silently dropped from the assertion. Filter out blank and comment lines before taking the first token, and fail with a clear message when okfProperties { is missing.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At datahub-agent-context/tests/unit/mcp_tools/test_okf_documents.py, line 34:
<comment>`test_gql_selects_okf_properties` extracts the `okfProperties` block by counting braces and then asserts on `line.split()[0]` of every line, so a blank line or `#` comment added inside the block raises a bare `IndexError`/corrupts the depth count, and fields placed on a shared line are silently dropped from the assertion. Filter out blank and comment lines before taking the first token, and fail with a clear message when `okfProperties {` is missing.</comment>
<file context>
@@ -0,0 +1,124 @@
+ ["document_search.gql", "document_semantic_search.gql", "document_okf.gql"],
+)
+def test_gql_selects_okf_properties(gql_file):
+ lines = (GQL_DIR / gql_file).read_text().splitlines()
+ first = next(i for i, line in enumerate(lines) if "okfProperties {" in line)
+ block, depth = [], 0
</file context>
| lines = (GQL_DIR / gql_file).read_text().splitlines() | |
| first = next(i for i, line in enumerate(lines) if "okfProperties {" in line) | |
| block, depth = [], 0 | |
| for line in lines[first:]: | |
| block.append(line) | |
| depth += line.count("{") - line.count("}") | |
| if depth == 0: | |
| break | |
| def test_gql_selects_okf_properties(gql_file): | |
| lines = (GQL_DIR / gql_file).read_text().splitlines() | |
| start = next( | |
| (i for i, line in enumerate(lines) if "okfProperties {" in line), | |
| None, | |
| ) | |
| assert start is not None, f"okfProperties block missing in {gql_file}" | |
| block, depth = [], 0 | |
| for line in lines[start:]: | |
| if not line.strip() or line.lstrip().startswith("#"): | |
| continue | |
| block.append(line) | |
| depth += line.count("{") - line.count("}") | |
| if depth == 0: | |
| break | |
| assert {line.split()[0] for line in block} >= OKF_SELECTION |
| [result] = get_entities([urn]) | ||
|
|
||
| assert result["urn"] == urn | ||
| assert "okfProperties" not in result |
There was a problem hiding this comment.
P2: Custom agent: Enforce Pragmatic Test Coverage
No test covers a document whose GetDocumentOkfProperties lookup succeeds but returns no okfProperties — the common non-OKF document case the PR description calls out. The existing tests cover the OKF-present and lookup-raises paths, but not the branch where entities.py's if okf_result and okf_result.get("okfProperties") guard is not taken. Add a test asserting "okfProperties" not in result after a successful-but-empty lookup, mirroring the failure test with a second response of {"entity": {"urn": urn, "okfProperties": None}}.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At datahub-agent-context/tests/unit/mcp_tools/test_okf_documents.py, line 107:
<comment>No test covers a document whose `GetDocumentOkfProperties` lookup succeeds but returns no `okfProperties` — the common non-OKF document case the PR description calls out. The existing tests cover the OKF-present and lookup-raises paths, but not the branch where `entities.py`'s `if okf_result and okf_result.get("okfProperties")` guard is not taken. Add a test asserting `"okfProperties" not in result` after a successful-but-empty lookup, mirroring the failure test with a second response of `{"entity": {"urn": urn, "okfProperties": None}}`.</comment>
<file context>
@@ -0,0 +1,124 @@
+ [result] = get_entities([urn])
+
+ assert result["urn"] == urn
+ assert "okfProperties" not in result
+
+
</file context>
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("filter_string", ["okf_id != x", "NOT okf_id = x"]) |
There was a problem hiding this comment.
P2: Custom agent: Enforce Pragmatic Test Coverage
The _negate_filter change makes NOT (a = x OR b = y) over plain custom fields compile to a != x AND b != y instead of raising, but the new tests exercise this De Morgan branch only through the okf_id alias. Add a direct test for the general path, e.g. in metadata-ingestion/tests/unit/cli/test_search_filter_parser.py (untouched by this PR), asserting parse_filter_string("NOT (a = x OR b = y)") == F.and_(F.not_(F.custom_filter("a", "EQUAL", ["x"])), F.not_(F.custom_filter("b", "EQUAL", ["y"]))) and the same via !=; otherwise a regression in this documented side effect ships silently.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At datahub-agent-context/tests/unit/mcp_tools/test_search_filter_parser.py, line 835:
<comment>The `_negate_filter` change makes `NOT (a = x OR b = y)` over plain custom fields compile to `a != x AND b != y` instead of raising, but the new tests exercise this De Morgan branch only through the `okf_id` alias. Add a direct test for the general path, e.g. in metadata-ingestion/tests/unit/cli/test_search_filter_parser.py (untouched by this PR), asserting `parse_filter_string("NOT (a = x OR b = y)") == F.and_(F.not_(F.custom_filter("a", "EQUAL", ["x"])), F.not_(F.custom_filter("b", "EQUAL", ["y"])))` and the same via `!=`; otherwise a regression in this documented side effect ships silently.</comment>
<file context>
@@ -804,3 +804,57 @@ def test_boolean_filter_combined_with_and():
+ )
+
+
+@pytest.mark.parametrize("filter_string", ["okf_id != x", "NOT okf_id = x"])
+def test_negated_okf_id_excludes_both_fields(filter_string):
+ assert parse_filter_string(filter_string) == F.and_(
</file context>
Connector Tests ResultsAll connector tests passed for commit To skip connector tests, add the Autogenerated by the connector-tests CI pipeline. |
OKF treats a missing status as stable. okf_status = stable (or an IN list containing stable) now also matches OKF documents that declare no status, and its negation excludes them. Tool descriptions say so, and note that okf_stale_after IS NULL also matches unreadable values.
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
- Hybrid search shapes OKF frontmatter after its final cleanup, so it keeps the same nulls, empty lists and nested values as keyword search. - Negation applies De Morgan recursively, so groups that contain okf_id (which spans two fields) can be negated. - okf_status != stable matches only OKF documents that declare another status. - New okf_bundle_root alias for the bundle root path, documented for use with okf_bundle.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f315a3b. Configure here.
| return F.and_(*(_negate_filter(b) for b in branches)) | ||
| if isinstance(inner, _And) and len(inner.compile()) > 1: | ||
| # NOT (A AND B) = NOT A OR NOT B, for groups _Not cannot negate. | ||
| return F.or_(*(_negate_filter(b) for b in inner.and_)) |
There was a problem hiding this comment.
Stable status negation breaks NOT
High Severity
Negating okf_status = stable adds okfStatus and okfConceptId EXISTS checks, and that narrowed result is reused as a boolean NOT. NOT (okf_status = stable OR platform = snowflake) then drops entities that are neither, and NOT NOT okf_status = stable matches nearly every non-OKF entity.
Reviewed by Cursor Bugbot for commit f315a3b. Configure here.
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="metadata-ingestion/src/datahub/cli/search_filter_parser.py">
<violation number="1" location="metadata-ingestion/src/datahub/cli/search_filter_parser.py:753">
P2: This OKF-only restriction breaks grouped De Morgan negation: `NOT (okf_status = stable AND type = document)` drops non-OKF documents of type `document`. Keep the narrower rule for direct `okf_status != stable`, but preserve the full complement when negating a group.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| return F.and_( | ||
| *(_negate_filter(b) for b in branches), | ||
| F.custom_filter("okfStatus", "EXISTS", []), | ||
| _is_okf_document(), |
There was a problem hiding this comment.
P2: This OKF-only restriction breaks grouped De Morgan negation: NOT (okf_status = stable AND type = document) drops non-OKF documents of type document. Keep the narrower rule for direct okf_status != stable, but preserve the full complement when negating a group.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At metadata-ingestion/src/datahub/cli/search_filter_parser.py, line 753:
<comment>This OKF-only restriction breaks grouped De Morgan negation: `NOT (okf_status = stable AND type = document)` drops non-OKF documents of type `document`. Keep the narrower rule for direct `okf_status != stable`, but preserve the full complement when negating a group.</comment>
<file context>
@@ -725,17 +737,27 @@ def _negate_filter(inner: Filter) -> Filter:
+ return F.and_(
+ *(_negate_filter(b) for b in branches),
+ F.custom_filter("okfStatus", "EXISTS", []),
+ _is_okf_document(),
+ )
+ # NOT (A OR B) = NOT A AND NOT B, applied recursively so groups that
</file context>


What
Agents using the
datahub-agent-contextdocument tools now see OKF metadata and can filter on it. The same change for the standalone MCP server is in acryldata/mcp-server-datahub#301. The two keep separate copies of the tools.search_documents(keyword and semantic) andget_entitieson a document returnokfProperties:type,status,conceptId,declaredId,description,staleAfter,bundle { location rootPath okfVersion }andfrontmatter. The frontmatter comes back as a JSON object, parsed after the last response cleanup. Keyword and hybrid search therefore return the same values, including nulls and empty lists. AboveOKF_FRONTMATTER_CHAR_LIMIT(4000 chars, env-configurable) it is left out andfrontmatterOmittedsays why. Documents without OKF get nothing extra (DocumentMapperreturns null for them).metadata-ingestion/src/datahub/cli/search_filter_parser.py, which agent-context re-exports anddatahub search --wherealso uses), all matched withIEQUAL:okf_type→okfTypeokf_status→okfStatusokf_bundle→okfBundleLocationokf_bundle_root→okfBundleRootPath. One repository can hold several bundles, so the descriptions show pinning a bundle withokf_bundleandokf_bundle_roottogether.okf_id→okfConceptIdORokfDeclaredIdokf_stale_after→okfStaleAfter, for>/</IS NULL(epoch ms)okf_status = stable(or anINlist containing it) becomesokfStatus IEQUAL stable OR (NOT EXISTS okfStatus AND EXISTS okfConceptId). Every OKF document has a conceptId, so that term keeps non-OKF documents out.okf_status != stable(andNOT okf_status = stable) matches only OKF documents that declare a status other than stable. Other values match as written.okf_stale_after IS NULLis not "never stale": it also matches documents whosestale_aftervalue could not be read.Negation applies De Morgan recursively, so
NOT okf_id = x,okf_id != xand groups such asNOT (okf_id = x OR okf_type = guide)work. Before,_Notrejected them becauseokf_idspans two fields.IS [NOT] NULLworks on every alias.As a side effect,
NOT (a = x OR b = y)over plain custom fields now compiles toa != x AND b != y. It used to raise "Cannot negate a filter with multiple OR clauses".FILTER_DOCSand thesearch_documents/get_entitiesdescriptions cover the aliases, searching by OKF id (query="guide:mau", Search V3), and thattypemeans entity type, so document types go throughsubtype/okf_type.Why it sits where it does
datahub search --where, so both pick them up.get_entitiesreads OKF with its own smallGetDocumentOkfPropertiesquery and does not add it toGetEntity.GetEntity's Document arm is a#[NEWER_GMS]block, which is off on non-Cloud servers, so OKF placed there would never reach OSS.strip_unsupported_fields=Trueprojects them away on servers beforeokfPropertiesexisted.Testing
metadata-ingestion/tests/unit/cli/test_search_filter_parser.py, next to the parser: each alias,okf_idand its negation,IS [NOT] NULL,okf_stale_aftercomparisons, andtypestill meaning entity type. Every new parser line is covered.New
test_okf_documents.py: the gql selections, frontmatter parse and omission, andget_entities(adds OKF for documents, survives a failed lookup, skips other entities).Checked by hand that the three queries validate against this branch's GraphQL schema.
:datahub-agent-context:lintpasses, and:datahub-agent-context:testFullpasses (690 passed).:metadata-ingestion:testSingleontests/unit/cli/test_search_filter_parser.pypasses (31 passed).:metadata-ingestion:lint: ruff passes. mypy reports errors only inazure_data_factoryfiles this PR doesn't touch.PR title follows the format
Tests added
Docs (tool descriptions) updated
No breaking changes
🤖 Opened with cclaude on behalf of @shirshanka