From 9152b626991481149f12d1e5065a354011e220c9 Mon Sep 17 00:00:00 2001 From: Sean Huh Date: Mon, 9 Nov 2026 18:34:16 -0800 Subject: [PATCH] Enable cross-type numeric comparisons by default in CelOptions.current() PiperOrigin-RevId: 1017813235 --- PLANNER_MIGRATION_GUIDE.md | 8 ++------ bundle/src/main/java/dev/cel/bundle/CelFactory.java | 2 +- common/src/main/java/dev/cel/common/CelOptions.java | 4 ++-- .../src/main/java/dev/cel/runtime/CelRuntimeFactory.java | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/PLANNER_MIGRATION_GUIDE.md b/PLANNER_MIGRATION_GUIDE.md index 4f012171e..397a36649 100644 --- a/PLANNER_MIGRATION_GUIDE.md +++ b/PLANNER_MIGRATION_GUIDE.md @@ -41,15 +41,11 @@ Cel cel = CelFactory.plannerCelBuilder().build(); > (`standardCelBuilder`, `legacyCelBuilder`, `standardCelRuntimeBuilder`, > `legacyCelRuntimeBuilder`) are deprecated. -If you are overriding `CelOptions`, ensure -`enableHeterogeneousNumericComparisons` is enabled, and remove any deprecated -options: +If you are overriding `CelOptions`, start from `CelOptions.current()` and remove +any deprecated options: ```java CelOptions options = CelOptions.current() - // Ensure this is explicitly toggled on (enabled by default in planner - // builders) - .enableHeterogeneousNumericComparisons(true) // Remove the following deprecated options if you have them set: // .enableUnsignedLongs(...) // .unwrapWellKnownTypesOnFunctionDispatch(...) diff --git a/bundle/src/main/java/dev/cel/bundle/CelFactory.java b/bundle/src/main/java/dev/cel/bundle/CelFactory.java index 653d7f8de..22e37fafc 100644 --- a/bundle/src/main/java/dev/cel/bundle/CelFactory.java +++ b/bundle/src/main/java/dev/cel/bundle/CelFactory.java @@ -78,7 +78,7 @@ public static CelBuilder plannerCelBuilder() { CelCheckerLegacyImpl.newBuilder().setStandardEnvironmentEnabled(true)), CelRuntimeImpl.newBuilder()) // CEL-Internal-2 - .setOptions(CelOptions.current().enableHeterogeneousNumericComparisons(true).build()); + .setOptions(CelOptions.DEFAULT); } /** Combines a prebuilt {@link CelCompiler} and {@link CelRuntime} into {@link Cel}. */ diff --git a/common/src/main/java/dev/cel/common/CelOptions.java b/common/src/main/java/dev/cel/common/CelOptions.java index 84ab99bcd..5131a9dd0 100644 --- a/common/src/main/java/dev/cel/common/CelOptions.java +++ b/common/src/main/java/dev/cel/common/CelOptions.java @@ -183,6 +183,7 @@ public static Builder current() { .enableUnsignedLongs(true) .enableRegexPartialMatch(true) .enableTimestampEpoch(true) + .enableHeterogeneousNumericComparisons(true) .errorOnDuplicateMapKeys(true) .evaluateCanonicalTypesToNativeValues(true) .errorOnIntWrap(true) @@ -323,8 +324,7 @@ public abstract static class Builder { * Enable the {@code less_equals_double_int64} and other cross-type numeric comparisons for * {@code double}, {@code int64}, and {@code uint64} values. * - *

This feature adds the declarations for these overloads to the CEL standard environment, - * but the runtime functions are enabled by default. + *

This option is enabled by default in {@link CelOptions#current}. * *

TODO: Remove this feature once it has been auto-enabled. */ diff --git a/runtime/src/main/java/dev/cel/runtime/CelRuntimeFactory.java b/runtime/src/main/java/dev/cel/runtime/CelRuntimeFactory.java index ad291b108..aecc52004 100644 --- a/runtime/src/main/java/dev/cel/runtime/CelRuntimeFactory.java +++ b/runtime/src/main/java/dev/cel/runtime/CelRuntimeFactory.java @@ -61,7 +61,7 @@ public static CelRuntimeBuilder legacyCelRuntimeBuilder() { public static CelRuntimeBuilder plannerRuntimeBuilder() { return CelRuntimeImpl.newBuilder() // CEL-Internal-2 - .setOptions(CelOptions.current().enableHeterogeneousNumericComparisons(true).build()); + .setOptions(CelOptions.DEFAULT); } private CelRuntimeFactory() {}