Skip to content

SubDocUpdate Parsers for FlatPostgresCollection#279

Open
suddendust wants to merge 14 commits intohypertrace:mainfrom
suddendust:pg_write_subDocOperatorRemainingParsers
Open

SubDocUpdate Parsers for FlatPostgresCollection#279
suddendust wants to merge 14 commits intohypertrace:mainfrom
suddendust:pg_write_subDocOperatorRemainingParsers

Conversation

@suddendust
Copy link
Contributor

Description

This PR implements sub-doc update parsers for flat collections.

Testing

[x] Added integration tests to validate the behaviour on PG.
[x] Added Mongo/PG compatibility test.

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

❌ Patch coverage is 86.23853% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.19%. Comparing base (cfc9c08) to head (5b7464a).

Files with missing lines Patch % Lines
.../parser/filter/nonjson/field/PostgresDataType.java 71.42% 3 Missing and 3 partials ⚠️
...1/vistors/PostgresFilterTypeExpressionVisitor.java 50.00% 1 Missing and 1 partial ⚠️
...postgres/update/parser/PostgresAddValueParser.java 90.00% 1 Missing and 1 partial ⚠️
...ter/PostgresInRelationalFilterParserJsonArray.java 0.00% 1 Missing ⚠️
...update/parser/PostgresAddToListIfAbsentParser.java 85.71% 0 Missing and 1 partial ⚠️
...gres/update/parser/PostgresAppendToListParser.java 85.71% 0 Missing and 1 partial ⚠️
...update/parser/PostgresRemoveAllFromListParser.java 87.50% 0 Missing and 1 partial ⚠️
...s/update/parser/PostgresUpdateOperationParser.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #279      +/-   ##
============================================
+ Coverage     81.01%   81.19%   +0.18%     
- Complexity     1446     1459      +13     
============================================
  Files           241      238       -3     
  Lines          6979     6977       -2     
  Branches        648      653       +5     
============================================
+ Hits           5654     5665      +11     
+ Misses          907      895      -12     
+ Partials        418      417       -1     
Flag Coverage Δ
integration 81.19% <86.23%> (+0.18%) ⬆️
unit 55.41% <17.43%> (+0.41%) ⬆️

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] SubDocUpdate Parsers for FlatPostgresCollection SubDocUpdate Parsers for FlatPostgresCollection Feb 26, 2026
suresh-prakash
suresh-prakash previously approved these changes Feb 26, 2026
ResultSet rs = ps.executeQuery()) {
assertTrue(rs.next());
assertEquals(999, rs.getInt("price"));
assertEquals(15, rs.getInt("price"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these changes intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if you look at the diff, the earlier code had List.of(SubDocumentUpdate.of("price", 999));, so I was asserting on 999. Now, it has this:

            List.of(
                SubDocumentUpdate.builder()
                    .subDocument("price")
                    .operator(UpdateOperator.ADD)
                    .subDocumentValue(
                        org.hypertrace.core.documentstore.model.subdoc.SubDocumentValue.of(5))
                    .build());

So, I am asserting on 5.

}

/** Returns the PostgreSQL type cast for the column type. */
private String getPostgresTypeCast(PostgresDataType columnType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be helpful to have it in a common class and use it for any numeric operators?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so, we might be doing these casts at multiple places. Will refactor if this is the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@suresh-prakash Refactored this. This touched 2 files in the query layer but I think it's okay.

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