Skip to content

Add Variant, Decimal, and Timestamp CEL functions - #524

Open
Robert Yokota (rayokota) wants to merge 36 commits into
masterfrom
add-cel-logical-types-2
Open

Add Variant, Decimal, and Timestamp CEL functions#524
Robert Yokota (rayokota) wants to merge 36 commits into
masterfrom
add-cel-logical-types-2

Conversation

@rayokota

Copy link
Copy Markdown
Member

Please prefix all TypeScript pull-requests with [Typescript]

What

Checklist

  • Contains customer facing changes? Including API/behavior changes
  • Did you add sufficient unit test and/or integration test coverage for this PR?
    • If not, please explain why it is not required

References

JIRA:

Test & Review

Open questions / Follow-ups

Copilot AI lite review requested due to automatic review settings August 24, 2026 23:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the Schema Registry JS client’s CEL and serde capabilities by adding first-class Decimal/Timestamp/Variant CEL support and introducing schema-declared inline validation rules across Avro, JSON Schema, and Protobuf, with extensive new parity-oriented tests.

Changes:

  • Add inline validation rules (schema-level confluent:rules / protobuf meta rules) with configurable execution timing and aggregated error reporting.
  • Add CEL built-ins and runtime wiring for Decimal, Timestamp, and Variant (including Avro logical type support and Variant path navigation).
  • Strengthen caching keys for parsed schemas to include references (avoiding cross-subject conflation) and add regression/parity test coverage.

Reviewed changes

Copilot reviewed 33 out of 34 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
schemaregistry/test/serde/validation-serdes.spec.ts Serializer-level tests for inline validation wiring across Avro/JSON/Protobuf, plus JSON schema caching and rule firing counts.
schemaregistry/test/serde/validate-message.spec.ts Walker-level tests verifying per-format validation traversal and field-path reporting; includes now and dynamic message checks.
schemaregistry/test/serde/test/validation_widget_pb.ts Generated protobuf test fixture carrying inline validation rules in options/meta.
schemaregistry/test/serde/protobuf.spec.ts Adds CEL decimal/timestamp coverage and nested-type CEL field transform coverage for protobuf serde.
schemaregistry/test/serde/protobuf-walk-parity.spec.ts Ensures parity between protobuf validation walk and transform walk, plus schema-view edge cases.
schemaregistry/test/serde/json.spec.ts Adds coverage for JSON Schema enum typing (enum/const without explicit type) in rule walking.
schemaregistry/test/serde/avro.spec.ts Adds CEL decimal/timestamp behavior tests, including fail-closed semantics and Avro logical-type handling.
schemaregistry/test/rules/cel/cel-executor.spec.ts Regression test ensuring CEL program caching is not incorrectly reused across registries.
schemaregistry/test/confluent/types/decimal-utils.spec.ts Tests for exact decimal conversions beyond decimal.js default precision limits.
schemaregistry/serde/serde.ts Introduces inline validation framework types/helpers, schema cache key helper, and serializer config options for validation.
schemaregistry/serde/json.ts Adds inline JSON validation walker and switches caches to use schema+references keying; avoids schema mutation on subtype checks.
schemaregistry/serde/avro.ts Adds inline Avro validation walker, schema+references cache keying, and an Avro variant logical type integration.
schemaregistry/rules/cel/variant-path.ts Implements JSONPath-like subset parser/walker for Variant navigation.
schemaregistry/rules/cel/variant-funcs.ts Adds CEL variant(...) constructor and variants.* accessors + JSON parsing/serialization.
schemaregistry/rules/cel/timestamp-funcs.ts Adds CEL timestamp constructor overloads with spec-aligned epoch semantics and range checks.
schemaregistry/rules/cel/is-funcs.ts Adds CEL string-format validators (isEmail, isHostname, etc.).
schemaregistry/rules/cel/decimal-funcs.ts Adds CEL Decimal constructor and decimals.* operators with BigDecimal-like scale/precision semantics and numeric equality.
schemaregistry/rules/cel/cel-validator.ts Adds CEL-backed inline validation rule executor with protobuf-registry-aware evaluation.
schemaregistry/rules/cel/cel-field-executor.ts Improves field-value presentation to CEL using protobuf field descriptors and Avro logical-type wrapping/unwrapping.
schemaregistry/rules/cel/cel-executor.ts Extends CEL executor with Decimal/Timestamp/Variant funcs, registry-aware plan caching, fail-closed behavior, and Avro logical-type wrapping.
schemaregistry/package.json Bumps @bufbuild/cel, bumps avsc, and adds decimal.js.
schemaregistry/index.ts Exports Variant types/utilities and clarifies Rule type exports to avoid name collisions.
schemaregistry/confluent/types/variant_pb.ts Generated protobuf for confluent.type.Variant.
schemaregistry/confluent/types/decimal-utils.ts Adds decimal conversion utilities between decimal.js and confluent.type.Decimal.
schemaregistry/confluent/meta_pb.ts Updates meta proto generation to include inline rules and adds confluent.Rule message.
proto/test/schemaregistry/serde/validation_widget.proto Test proto defining inline validation rule fixtures.
proto/confluent/types/variant.proto Defines the confluent.type.Variant proto.
proto/confluent/meta.proto Extends Meta with repeated Rule and defines the Rule message.
package-lock.json Lockfile updates for dependency bumps/additions.
CHANGELOG.md Notes inline validation rules enhancement.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +33 to +35
export function schemaCacheKey(info: SchemaInfo): string {
return stringify(minimize(info))
}
Comment on lines +1467 to +1477
let detail: string | undefined
if (this.message) {
detail = this.message
} else if (this.rule?.doc) {
detail = this.rule.doc
} else if (this.rule?.sql) {
detail = this.rule.sql
} else {
detail = this.rule?.expr
}
let result = `${path}: ${name}: ${detail}`
Comment on lines +142 to +154
function readIndex(cur: Cursor, path: string): number {
if (cur.hasMore() && cur.peek() === "-") {
throw new Error("negative indices are not supported in variant path: " + path);
}
const start = cur.pos;
while (cur.hasMore() && cur.peek() >= "0" && cur.peek() <= "9") {
cur.next();
}
if (cur.pos === start) {
throw new Error("expected integer index in variant path: " + path);
}
return Number(cur.src.slice(start, cur.pos));
}
Comment on lines 41 to 46
async transform(ctx: RuleContext, msg: any): Promise<any> {
const args = {
message: msg
message: this.wrapForCel(ctx, msg),
}
return await this.execute(ctx, msg, args)
}
Comment thread CHANGELOG.md
1. Support generating a JSON Schema title from a JSON payload (#505)
2. Add support for saving Azure key version with DEK (#507)
3. Pass context when clients make KEK calls to DEK Registry (#508)
4. Add support for inline validation rules (#522)
@sonarqube-confluent

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
78.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants