Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
00e9a9c
Added PostgresSchemaRegistry.java
suddendust Dec 28, 2025
31846e9
Spotless
suddendust Dec 28, 2025
2fdbf0e
WIP
suddendust Dec 29, 2025
1727dd0
Spotless
suddendust Dec 29, 2025
a62fbc2
Remove unused method in SchemaRegistry
suddendust Dec 29, 2025
6b7595b
Remove unused method in ColumnMetadata
suddendust Dec 29, 2025
7b4ef2a
WIP
suddendust Dec 29, 2025
598cb25
WIP
suddendust Dec 29, 2025
9c173b9
Configure cache expiry and cooldown
suddendust Dec 29, 2025
7bf77c5
Added PostgresMetadataFetcherTest
suddendust Dec 29, 2025
6d03cd5
WIP
suddendust Dec 29, 2025
c3f5f7e
Added docs on thread safety
suddendust Dec 29, 2025
827381f
Added PostgresSchemaRegistryIntegrationTest.java
suddendust Dec 29, 2025
602037b
WIP
suddendust Dec 29, 2025
c8a53eb
WIP
suddendust Dec 30, 2025
31f16e2
Refactor
suddendust Jan 4, 2026
c139bee
Merge branch 'schema_cache' into pg_write_create
suddendust Jan 4, 2026
75150e3
Merge branch 'main' of github.com:hypertrace/document-store into sche…
suddendust Jan 11, 2026
5412f9b
Merge branch 'schema_cache' into pg_write_create
suddendust Jan 12, 2026
bf5ca5c
WIP
suddendust Jan 12, 2026
57b623a
Implement create for flat collections
suddendust Jan 12, 2026
233c9c4
Merge branch 'main' of github.com:hypertrace/document-store into pg_w…
suddendust Jan 12, 2026
9f8811e
Fix compilation issue
suddendust Jan 12, 2026
bfd6651
Refactor
suddendust Jan 14, 2026
70ec4b3
Enhanced CreateResult.java and others
suddendust Jan 14, 2026
6d1c277
Added more test cases
suddendust Jan 14, 2026
910ef8c
Spotless
suddendust Jan 14, 2026
3e2c178
WIP
suddendust Jan 14, 2026
9061e24
Add more test coverage
suddendust Jan 14, 2026
c3024b0
Added `bestEfforts` configuration to PG custom parameters.
suddendust Jan 16, 2026
900c87f
Create MissingColumnStrategy.java
suddendust Jan 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,16 +1,51 @@
package org.hypertrace.core.documentstore;

import java.util.Collections;
import java.util.List;
import lombok.Getter;

/*
* Represent the result object for CREATE operation of document store APIs.
* */
@Getter
public class CreateResult {
private boolean succeed;

public CreateResult(boolean succeed) {
this.succeed = succeed;
private final CreateStatus status;
private final boolean onRetry;
private final List<String> skippedFields;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can be a set.


public CreateResult(CreateStatus status, boolean onRetry, List<String> skippedFields) {
this.status = status;
this.onRetry = onRetry;
this.skippedFields = skippedFields != null ? skippedFields : Collections.emptyList();
}

public CreateResult(boolean isSuccess) {
this(isSuccess ? CreateStatus.SUCCESS : CreateStatus.FAILED, false, Collections.emptyList());
}

public CreateResult(boolean isSucceed, boolean onRetry, List<String> skippedFields) {
this(determineStatus(isSucceed, skippedFields), onRetry, skippedFields);
}

private static CreateStatus determineStatus(boolean isSucceed, List<String> skippedFields) {
if (!isSucceed) {
return CreateStatus.FAILED;
}
return (skippedFields != null && !skippedFields.isEmpty())
? CreateStatus.PARTIAL
: CreateStatus.SUCCESS;
}

public boolean isSucceed() {
return succeed;
return status == CreateStatus.SUCCESS || status == CreateStatus.PARTIAL;
}

public boolean isPartial() {
return status == CreateStatus.PARTIAL;
}

public boolean isDocumentIgnored() {
return status == CreateStatus.IGNORED;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.hypertrace.core.documentstore;

/** Status of a document create operation. */
public enum CreateStatus {
/** Document created successfully with all fields. */
SUCCESS,

/** Document created but some fields were skipped (didn't match schema). */
PARTIAL,

/** Document was intentionally not created due to IGNORE_DOCUMENT strategy. */
IGNORED,

/** Operation failed (no valid columns found or other error). */
FAILED
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ public interface ColumnMetadata {
* @return whether this column can be set to NULL
*/
boolean isNullable();

/**
* @return whether this column is an array type
*/
boolean isArray();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.hypertrace.core.documentstore.model.exception;

import java.io.IOException;

/**
* Exception thrown when a document field doesn't match the expected schema. This can occur when:
*
* <ul>
* <li>A field in the document doesn't exist in the schema
* <li>A field's value type doesn't match the expected schema type
* </ul>
*/
public class SchemaMismatchException extends IOException {

public SchemaMismatchException(String message) {
super(message);
}

public SchemaMismatchException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.hypertrace.core.documentstore.model.options;

/**
* Strategy for handling document fields that don't match the schema during write operations. This
* is mostly applicable to flat collections as they conform to a schema
*
* <p>This enum defines how the system should behave when encountering fields that either don't
* exist in the schema or have incompatible types.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also mention what is the default (in case not specified)? Or, is it a mandatory field?

Copy link
Contributor

Choose a reason for hiding this comment

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

The default can go in @implSpec annotated documentation comment so that every implementor would agree to this specification.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even better would be to expose a static method called MissingColumnStrategy.default() so that it is self-documented (and gives an opportunity to later change the default across all implementations in a single go).

public enum MissingColumnStrategy {
/**
* Skip unmatched fields and continue with the write operation. The document will be written with
* only the fields that match the schema.
*/
SKIP,

/**
* Throw a {@link org.hypertrace.core.documentstore.model.exception.SchemaMismatchException} when
* a field doesn't match the schema. The write operation will fail.
*/
THROW,
IGNORE_DOCUMENT
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can also come in later when the need arises.

}
Loading
Loading