Support custom column names for PgVectorStore (partial implementation) #5216
+320
−13
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.
Description
This pull request is an initial step toward addressing
#1934.
Currently,
PgVectorStoreassumes fixed column names (id,content,metadata,embedding), which makes it difficult to integrate with existing database schemas. This PR introduces a column-mapping approach that allows customizing column names, starting with the most critical paths.What’s included in this PR
Column name mapping for table creation and inserts
CREATE TABLE) and insert/upsert logic now use configurable column names instead of hardcoded ones.Schema validation updated accordingly (todo)
PgVectorSchemaValidatorhas been updated to validate against the configured column names rather than fixed defaults.Integration tests added
New integration tests verify that:
...(will be added after confirm)
Tests are implemented using the existing Testcontainers +
ApplicationContextRunnerstyle and confirm the behavior end-to-end.What’s intentionally left out (for now)
This PR does not yet update all SQL paths (e.g. similarity search, delete, etc.).
Before expanding the change further, I wanted to confirm that this approach and API direction are acceptable to the maintainers.
If this direction looks good, I’m happy to follow up with additional PRs to:
Affected files
PgVectorStorePgVectorSchemaValidatorThank you for taking the time to review this contribution.
I’m looking forward to your feedback on the approach before continuing with the remaining changes.