feat(ers): add postgres_object SQL transformation - #3798
Draft
ryanulit wants to merge 2 commits into
Draft
Conversation
Add a postgres_object transformation that parses a PostgreSQL JSON/JSONB result column into a map[string]any so nested attribute objects can be surfaced as entity resolution claims. Accepts string, []byte, or a pre-decoded map from the pgx driver. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Ryan Yanulites <ryanulites@virtru.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Contributor
OutputMapper.applyTransformation held a hand-rolled switch that was never updated when new transformations were added to the transformation package (postgres_array and now postgres_object both errored at runtime with "unknown transformation"). Delegate to transformation.DefaultRegistry.ApplyTransformation, passing the provider type from RawResult.Metadata so provider-specific transformations dispatch correctly. Any transformation registered in the transformation package now works end-to-end with no additional wiring. To preserve prior behavior: - Add a trim common transformation. - ApplyCSVToArray now drops empty entries after trimming. - ApplyLDAPDNToCNArray now also accepts a single DN string. Add output_mapper_test.go covering the live path so this class of drift regresses loudly next time. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Ryan Yanulites <ryanulites@virtru.com>
Contributor
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Contributor
|
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
postgres_objectSQL transformation that decodes a PostgreSQL JSON/JSONB result column into amap[string]any, so nested attribute objects can be surfaced as entity-resolution claims.string,[]byte(as returned by the pgx driver for JSON/JSONB), or an already-decodedmap[string]any.nil/empty input yields an empty map; non-object JSON or unsupported input types return an error.GetSQLTransformations()so the existingtransformation.DefaultRegistry+ SQL mapper pipeline picks it up automatically — no additional wiring required insql_mapper.go.Test plan
go test ./service/entityresolution/multi-strategy/...— all packages pass.go vet ./service/entityresolution/multi-strategy/...clean.transformation/sql_test.gocovers JSON string, JSONB[]byte, passthrough map, nested objects, empty/nil, invalid JSON, JSON-array rejection, and unsupported input types.TestSQLMapper_TransformResultsextended with apostgres_objectcase;TestSQLMapper_GetSupportedTransformationsand constants tests updated.🤖 Generated with Claude Code