Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PROMPT TO THE AGENT
Document-Store Library PostgreSQL Query Interface Refactoring
CONTEXT & BACKGROUND
You are working with the document-store library, which provides a QueryLayer interface for consuming services. The library has two critical interfaces:
SCOPE: Focus exclusively on the PostgreSQL implementation located at:
@document-store/src/main/java/org/hypertrace/core/documentstore/postgres
Specifically, concentrate on the PostgreSQL implementations of:
CURRENT PROBLEM
The PostgreSQL implementation of the query interface has a critical limitation:
REFACTORING GOALS
Primary Goal (Priority 1):
Extend query generation support to include these data types while maintaining extensible design:
Secondary Goal (Future Enhancement):
The output parsing already exists in:
@document-store/src/main/java/org/hypertrace/core/documentstore/postgres/PostgresCollection.java:PostgresResultIteratorWithBasicTypes:prepareDocument
Query results should be parsed and returned as JsonNode (acknowledge existing support, will enhance later).
CURRENT IMPLEMENTATION DETAILS
Existing Workaround:
A temporary solution exists in FieldToPgColumnTransformer:transform that handles first-class fields based on:
flatStructureCollection.equals(postgresQueryParser.getTableIdentifier().getTableName())
Recent Interface Additions:
The following interfaces have been created for SQL query generation for first-class fields:
IMPLEMENTATION REQUIREMENTS
Mandatory Constraints:
The registry-based approach should replace the current hardcoded pattern:
flatStructureCollection.equals(context.getTableIdentifier().getTableName()...
<NewlyCreatedRegistry>:<isFirstClassColumn>
This registry lookup will determine whether to use JSON or non-JSON parser implementations. The decision affects the following parser pairs:
PostgresContainsRelationalFilterParser
(JSON) vsPostgresContainsRelationalFilterParserNonJsonField
(non-JSON)PostgresInRelationalFilterParser
(JSON) vsPostgresInRelationalFilterParserNonJsonField
(non-JSON)Additional parser classes that currently handle only JSON-based query generation must have corresponding non-JSON implementations created. Reference implementations for the non-JSON variants are available at:
document-store/src/main/java/org/hypertrace/core/documentstore/postgres/query/v1/parser/filter/nonjson/field/
Input/Output Specification:
DELIVERABLES
Please provide:
SUCCESS CRITERIA
ADDITIONAL NOTES