Skip to content

feat(ers): add postgres_object SQL transformation - #3798

Draft
ryanulit wants to merge 2 commits into
mainfrom
fix/add-object-sql-transformation
Draft

feat(ers): add postgres_object SQL transformation#3798
ryanulit wants to merge 2 commits into
mainfrom
fix/add-object-sql-transformation

Conversation

@ryanulit

Copy link
Copy Markdown
Contributor

Summary

  • Add a new postgres_object SQL transformation that decodes 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 (as returned by the pgx driver for JSON/JSONB), or an already-decoded map[string]any. nil/empty input yields an empty map; non-object JSON or unsupported input types return an error.
  • Registered in GetSQLTransformations() so the existing transformation.DefaultRegistry + SQL mapper pipeline picks it up automatically — no additional wiring required in sql_mapper.go.

Test plan

  • go test ./service/entityresolution/multi-strategy/... — all packages pass.
  • go vet ./service/entityresolution/multi-strategy/... clean.
  • New transformation/sql_test.go covers JSON string, JSONB []byte, passthrough map, nested objects, empty/nil, invalid JSON, JSON-array rejection, and unsupported input types.
  • TestSQLMapper_TransformResults extended with a postgres_object case; TestSQLMapper_GetSupportedTransformations and constants tests updated.

🤖 Generated with Claude Code

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>
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 19494039-5263-42d3-80b6-f85b4d5cf72c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 191.698253ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 103.809792ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 438.676784ms
Throughput 227.96 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 51.437688966s
Average Latency 512.538874ms
Throughput 97.20 requests/second

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>
@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 198.497981ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 100.721475ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 440.195491ms
Throughput 227.17 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 48.905681383s
Average Latency 486.958607ms
Throughput 102.24 requests/second

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • examples
  • otdfctl
  • sdk
  • service
  • lib/fixtures
  • tests-bdd

See the workflow run for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant