Skip to content

Commit 6aea041

Browse files
committed
Remove unused warnings field and related logic from NowEvaluator and conditionally generate it in EvaluatorImplementer.
1 parent 4e4df61 commit 6aea041

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/EvaluatorImplementer.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,32 @@ private TypeSpec type() {
9292
processFunction.args.forEach(a -> a.declareField(builder));
9393
builder.addField(DRIVER_CONTEXT, "driverContext", Modifier.PRIVATE, Modifier.FINAL);
9494

95-
builder.addField(WARNINGS, "warnings", Modifier.PRIVATE);
95+
var hasFixedProcessFunctionArgs = processFunction.args.stream()
96+
.anyMatch(x -> x instanceof FixedArgument == false);
97+
var usesWarnings = processFunction.warnExceptions.isEmpty() == false || hasFixedProcessFunctionArgs;
9698

99+
if (usesWarnings) {
100+
builder.addField(WARNINGS, "warnings", Modifier.PRIVATE);
101+
}
97102
builder.addMethod(ctor());
98103
builder.addMethod(eval());
99104
builder.addMethod(processFunction.baseRamBytesUsed());
100105

101106
if (processOutputsMultivalued) {
102-
if (processFunction.args.stream().anyMatch(x -> x instanceof FixedArgument == false)) {
107+
if (hasFixedProcessFunctionArgs) {
103108
builder.addMethod(realEval(true));
104109
}
105110
} else {
106-
if (processFunction.args.stream().anyMatch(x -> x instanceof FixedArgument == false)) {
111+
if (hasFixedProcessFunctionArgs) {
107112
builder.addMethod(realEval(true));
108113
}
109114
builder.addMethod(realEval(false));
110115
}
111116
builder.addMethod(processFunction.toStringMethod(implementation));
112117
builder.addMethod(processFunction.close());
113-
builder.addMethod(warnings());
118+
if (usesWarnings) {
119+
builder.addMethod(warnings());
120+
}
114121
return builder.build();
115122
}
116123

x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowEvaluator.java

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)