Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,8 @@ public final class ProgramPlanner {
private static final String JSON_NAME_EXTENSION = "json_name";
private static final String SELECT_OPTIMIZATION_EXTENSION = "select_optimization";

private static final ImmutableMap<String, Version> SUPPORTED_RUNTIME_EXTENSIONS =
ImmutableMap.of(
CEL_BLOCK_EXTENSION, Version.of(1, 1),
JSON_NAME_EXTENSION, Version.of(1, 1),
SELECT_OPTIMIZATION_EXTENSION, Version.of(1, 0));
private static final ImmutableSet<String> SUPPORTED_RUNTIME_EXTENSIONS =
ImmutableSet.of(CEL_BLOCK_EXTENSION, JSON_NAME_EXTENSION, SELECT_OPTIMIZATION_EXTENSION);

private final CelTypeProvider typeProvider;
private final CelValueProvider valueProvider;
Expand Down Expand Up @@ -865,11 +862,8 @@ private static PlannerContext create(CelAbstractSyntaxTree ast, CelOptions optio
continue;
}
Version version = extension.version();
Version supportedVersion = SUPPORTED_RUNTIME_EXTENSIONS.get(extension.id());
checkArgument(
supportedVersion != null
&& version.major() == supportedVersion.major()
&& version.minor() <= supportedVersion.minor(),
SUPPORTED_RUNTIME_EXTENSIONS.contains(extension.id()) && version.major() == 1,
"unsupported CEL extension: %s@%s.%s",
extension.id(),
version.major(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,8 @@ public void plan_notSet_throws() {
@Test
@TestParameters("{id: 'unknown', major: 1, minor: 0}")
@TestParameters("{id: 'select_optimization', major: 2, minor: 0}")
@TestParameters("{id: 'select_optimization', major: 1, minor: 1}")
@TestParameters("{id: 'cel_block', major: 0, minor: 0}")
@TestParameters("{id: 'cel_block', major: 1, minor: 2}")
@TestParameters("{id: 'json_name', major: 1, minor: 2}")
@TestParameters("{id: 'json_name', major: 2, minor: 0}")
public void plan_unsupportedRuntimeExtension_throws(String id, int major, int minor) {
CelAbstractSyntaxTree ast =
newAstWithExtensions(
Expand All @@ -377,9 +375,9 @@ public void plan_supportedOrNonRuntimeExtensions_succeeds() throws Exception {
CelAbstractSyntaxTree ast =
newAstWithExtensions(
Extension.create("cel_block", Version.of(1, 0), Component.COMPONENT_RUNTIME),
Extension.create("cel_block", Version.of(1, 1), Component.COMPONENT_RUNTIME),
Extension.create("json_name", Version.of(1, 1), Component.COMPONENT_RUNTIME),
Extension.create("select_optimization", Version.of(1, 0), Component.COMPONENT_RUNTIME),
Extension.create("cel_block", Version.of(1, 2), Component.COMPONENT_RUNTIME),
Extension.create("json_name", Version.of(1, 2), Component.COMPONENT_RUNTIME),
Extension.create("select_optimization", Version.of(1, 1), Component.COMPONENT_RUNTIME),
// Extensions not affecting the runtime are ignored.
Extension.create("unknown", Version.of(2, 0), Component.COMPONENT_PARSER));
ProgramPlanner planner =
Expand Down
Loading