Skip to content

Conversation

@suddendust
Copy link
Contributor

@suddendust suddendust commented Dec 21, 2025

Description

Currently, write methods accept a Document which is just a JSON string with no type info. This works for Mongo because of its schemaless nature, but for Postgres, we need the type info for these fields. This PR introduces a TypedDocument which contains this info.

@codecov
Copy link

codecov bot commented Dec 21, 2025

Codecov Report

❌ Patch coverage is 67.88321% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.15%. Comparing base (35fac78) to head (56a0d9c).

Files with missing lines Patch % Lines
...documentstore/postgres/FlatPostgresCollection.java 65.26% 25 Missing and 8 partials ⚠️
...g/hypertrace/core/documentstore/TypedDocument.java 73.80% 11 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #261      +/-   ##
============================================
- Coverage     80.41%   80.15%   -0.27%     
  Complexity     1337     1337              
============================================
  Files           231      232       +1     
  Lines          6060     6197     +137     
  Branches        545      568      +23     
============================================
+ Hits           4873     4967      +94     
- Misses          813      849      +36     
- Partials        374      381       +7     
Flag Coverage Δ
integration 80.15% <67.88%> (-0.27%) ⬇️
unit 56.94% <0.72%> (-1.28%) ⬇️

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.

return fields;
}

/** Returns a specific field by name, or null if not present. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of returning null, it'd be safer to return Optional.

public enum FieldKind {
SCALAR,
ARRAY,
JSONB
Copy link
Contributor

Choose a reason for hiding this comment

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

JSONB is specific to Postgres. Can we call it NESTED or something like that?

* @param value the value (typically a Map or object that can be serialized to JSON)
* @return this builder
*/
public Builder jsonbField(String name, Object value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same naming nit.

}

@Override
public String toJson() {

Choose a reason for hiding this comment

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

how does this behave for existing Document implementations?

}

/** Returns the DataType for scalar fields, or the element type for array fields. */
public DataType getDataType() {

Choose a reason for hiding this comment

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

how would this behave for jsonb?

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.

3 participants