Skip to content

feat(entities): support havingFilter post-aggregation filter [DS-9078] - #1863

Open
aayushuipath wants to merge 3 commits into
mainfrom
feat/entities-having-filter
Open

feat(entities): support havingFilter post-aggregation filter [DS-9078]#1863
aayushuipath wants to merge 3 commits into
mainfrom
feat/entities-having-filter

Conversation

@aayushuipath

@aayushuipath aayushuipath commented Aug 14, 2026

Copy link
Copy Markdown

What

Adds having_filter (SQL HAVING) support to entities_service.retrieve_records / retrieve_records_async, mirroring the TS SDK change (UiPath/uipath-typescript#647) for the Data Fabric query endpoint.

  • New models: EntityHavingFilter, EntityHavingCondition, EntityHavingOperator (=, !=, >, >=, <, <=), exported from uipath.platform.entities
  • having_filter is serialized as havingFilter in the query body
  • Local validation: having_filter without aggregates + group_by raises ValueError before any HTTP call (same rule the server enforces, clearer error)
  • Docstrings updated with args + a HAVING example; version bumped 0.2.18 -> 0.2.19 (required in-PR by check-version-availability)

Scope notes (matches the backend contract)

  • HAVING conditions reference declared aggregate aliases only; row-level conditions stay in filter_group
  • Native (LDO) entities only; federated entities and the SQL /query/execute path return 400 server-side
  • Gated by the enable-having-on-query feature flag on the backend; max 5 conditions (server-enforced)

Do not merge yet

Merging publishes 0.2.19 to PyPI via CD (the check-version-availability gate requires the bump in-PR, so the release cannot be split out). The backend reaches production rings Aug 24-28; releasing before then would let clients send havingFilter to servers that silently ignore unknown properties and return unfiltered results. This note will be removed once the backend is confirmed on prod.

Companion PRs

Testing

  • pytest packages/uipath-platform/tests/: 1645 passed, 0 failed (7 pre-existing credential-gated skips)
  • New tests: wire-format assertion (camelCase havingFilter body) and local validation error
  • ruff check, ruff format --check, mypy: clean

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings August 14, 2026 05:54
@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-integrations labels Aug 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds SQL HAVING-style post-aggregation filtering support to the Data Fabric Entities structured query (EntitiesService.retrieve_records / retrieve_records_async) in uipath-platform, including new request models, request-body serialization, and local preflight validation.

Changes:

  • Introduces EntityHavingFilter / EntityHavingCondition / EntityHavingOperator models and exports them from uipath.platform.entities.
  • Extends structured-query request building to serialize having_filter as havingFilter and validates that having_filter is only used with aggregates + group_by.
  • Adds tests for wire-format serialization and local validation; bumps uipath-platform version to 0.2.19 and updates lockfiles.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/uipath/uv.lock Updates locked editable dependency version for uipath-platform to 0.2.19.
packages/uipath-platform/uv.lock Updates locked package version for uipath-platform to 0.2.19.
packages/uipath-platform/tests/services/test_entities_service.py Adds tests for havingFilter wire serialization and local validation error behavior.
packages/uipath-platform/src/uipath/platform/entities/entities.py Adds HAVING-related models (EntityHaving*) alongside existing structured-query models.
packages/uipath-platform/src/uipath/platform/entities/_entity_data_service.py Adds having_filter plumbing + local validation + JSON serialization to the query request spec builder.
packages/uipath-platform/src/uipath/platform/entities/_entities_service.py Exposes having_filter on the public facade methods and documents usage with an example.
packages/uipath-platform/src/uipath/platform/entities/init.py Exports new HAVING models from the public entities module.
packages/uipath-platform/pyproject.toml Bumps uipath-platform version to 0.2.19.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 1 to +3
[project]
name = "uipath-platform"
version = "0.2.18"
version = "0.2.19"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Dropped the version bump (and lockfile updates) from this PR, so merging no longer publishes anything; the 0.2.19 bump will go in a small follow-up PR once the backend rollout completes. Updated the PR description to match.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: the split does not work in this repo. The check-version-availability gate fails any PR whose package files change without an unpublished version in pyproject.toml, so the bump has to ride along. Restored it and kept the do-not-merge hold in the description instead.

Comment on lines +1531 to +1537
body = json.loads(sent.content)
assert body["havingFilter"] == {
"logicalOperator": 0,
"aggregateFilters": [
{"aggregateAlias": "total", "operator": ">", "value": "5"}
],
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hard-coded 0 is deliberate here: this test pins the exact wire contract the server sees. If it asserted LogicalOperator.And.value, the test would keep passing even if the enum's value were accidentally changed, which is precisely the regression it should catch.

@github-actions

Copy link
Copy Markdown

🚨 Heads up: uipath-langchain cross-tests are FAILING 🚨

Your changes may break the uipath-langchain-python integration.

⚠️ These checks are NOT enforced by branch protection rules. Please review the failures before merging.

🔍 Inspect the failed run →

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants