Skip to content

Conversation

@suddendust
Copy link
Contributor

@suddendust suddendust commented Jan 15, 2026

PR Summary: Implement SET Operator for Flat PostgreSQL Collections

What

Adds support for the SET update operator on flat PostgreSQL collections, enabling sub-document updates on both top-level columns and nested JSONB paths.

Why

To provide MongoDB-like $set semantics for flat collections, allowing updates to specific fields without replacing entire documents.

Behavior

SET operator handles these scenarios:

Scenario Behavior
Field not in schema Skipped (with SKIP strategy) or throws (with THROW strategy)
Field is in schema but is NULL That value is SET
JSONB column is NULL Initializes to {} and sets the key
JSONB path exists Updates the value
JSONB path doesn't exist Creates the key

Key behaviors:

  • For JSONB columns, uses jsonb_set(..., true) to create missing keys
  • Uses COALESCE(column, '{}') to handle NULL JSONB columns
  • When all update paths are skipped (e.g., none resolve to valid columns), the update is a no-op rather than failing

Assumptions

  1. Depth-1 JSONB paths only — Nested paths within JSONB columns are assumed to be at most 1 level deep (e.g., customAttributes.myKey). Deeper paths would require recursive path creation which is not implemented yet.

  2. MissingColumnStrategy applies to updates — The existing missingColumnStrategy configuration (SKIP/THROW/IGNORE_DOCUMENT) governs behavior when update paths don't resolve to schema columns.

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 84.66667% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.70%. Comparing base (a45e01d) to head (d0bc0ab).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...documentstore/postgres/FlatPostgresCollection.java 88.49% 7 Missing and 6 partials ⚠️
.../parser/FlatCollectionSubDocSetOperatorParser.java 78.57% 6 Missing ⚠️
...cumentstore/postgres/update/FlatUpdateContext.java 55.55% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #267      +/-   ##
============================================
+ Coverage     80.52%   80.70%   +0.17%     
- Complexity     1392     1394       +2     
============================================
  Files           237      239       +2     
  Lines          6379     6529     +150     
  Branches        584      601      +17     
============================================
+ Hits           5137     5269     +132     
- Misses          854      868      +14     
- Partials        388      392       +4     
Flag Coverage Δ
integration 80.70% <84.66%> (+0.17%) ⬆️
unit 55.93% <4.00%> (-1.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@suddendust suddendust changed the title [Draft] Flat collections sub-doc updates SET Flat collections sub-doc updates SET Jan 20, 2026
@suddendust suddendust changed the title Flat collections sub-doc updates SET Subdoc SET Operator for Flat Collections Jan 20, 2026
@suresh-prakash suresh-prakash merged commit c855b61 into hypertrace:main Jan 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants