Skip to content

Commit 14e70bb

Browse files
authored
Merge branch 'main' into fix-filter-ccs
2 parents 9cc3fad + 3495b4e commit 14e70bb

File tree

8 files changed

+72
-7
lines changed

8 files changed

+72
-7
lines changed

distribution/tools/keystore-cli/src/test/java/org/elasticsearch/cli/keystore/AddStringKeyStoreCommandTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public void testStdinInputWithCarriageReturn() throws Exception {
193193
String password = "keystorepassword";
194194
KeyStoreWrapper.create().save(env.configDir(), password.toCharArray());
195195
terminal.addSecretInput(password);
196-
terminal.addSecretInput("Typedthisandhitenter\r");
196+
terminal.addSecretInput("Typedthisandhitenter\r\n");
197197
execute("-x", "foo");
198198
assertSecureString("foo", "Typedthisandhitenter", password);
199199
}

docs/changelog/126397.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126397
2+
summary: "ESQL: Preserve single aggregate when all attributes are pruned"
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 126392

server/src/main/java/org/elasticsearch/search/internal/CancellableBulkScorer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class CancellableBulkScorer extends BulkScorer {
2424

2525
// we use the BooleanScorer window size as a base interval in order to make sure that we do not
2626
// slow down boolean queries
27-
private static final int INITIAL_INTERVAL = 1 << 11;
27+
private static final int INITIAL_INTERVAL = 1 << 12;
2828

2929
// No point in having intervals that are larger than 1M
3030
private static final int MAX_INTERVAL = 1 << 20;

x-pack/plugin/esql/qa/testFixtures/src/main/resources/eval.csv-spec

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,3 +637,39 @@ foo:keyword
637637
;
638638

639639

640+
evalAfterAvgUsingSameName
641+
required_capability: remove_empty_attribute_in_merging_output
642+
from employees
643+
| stats avg = avg(salary)
644+
| eval avg = 12
645+
;
646+
647+
avg:integer
648+
12
649+
;
650+
651+
evalAfterStatsUsingSameName
652+
required_capability: remove_empty_attribute_in_merging_output
653+
from employees
654+
| stats count = count(emp_no), median = median(salary), top_salaries = TOP(salary, 3, "desc")
655+
| keep median, top_salaries
656+
| rename top_salaries as median
657+
| eval median = 12
658+
;
659+
660+
median:integer
661+
12
662+
;
663+
664+
evalAfterStatsUsingSameName2
665+
required_capability: remove_empty_attribute_in_merging_output
666+
ROW foo = [10, 11, 12]
667+
| mv_expand foo
668+
| stats sum = sum(foo), max = max(foo)
669+
| rename sum as max
670+
| eval max = 13
671+
;
672+
673+
max:integer
674+
13
675+
;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,12 @@ public enum Cap {
412412
*/
413413
RENAME_SEQUENTIAL_PROCESSING,
414414

415+
/**
416+
* Support for removing empty attribute in merging output.
417+
* See <a href="https://github.com/elastic/elasticsearch/issues/126392"> ESQL: EVAL after STATS produces an empty column #126392 </a>
418+
*/
419+
REMOVE_EMPTY_ATTRIBUTE_IN_MERGING_OUTPUT,
420+
415421
/**
416422
* Fix for union-types when some indexes are missing the required field. Done in #111932.
417423
*/

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PruneColumns.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.elasticsearch.compute.data.BlockUtils;
1212
import org.elasticsearch.index.IndexMode;
1313
import org.elasticsearch.xpack.esql.core.expression.AttributeSet;
14-
import org.elasticsearch.xpack.esql.core.expression.EmptyAttribute;
1514
import org.elasticsearch.xpack.esql.core.expression.Expressions;
1615
import org.elasticsearch.xpack.esql.core.expression.NamedExpression;
1716
import org.elasticsearch.xpack.esql.core.util.Holder;
@@ -77,7 +76,7 @@ public LogicalPlan apply(LogicalPlan plan) {
7776
if (aggregate.groupings().isEmpty()) {
7877
p = new LocalRelation(
7978
aggregate.source(),
80-
List.of(new EmptyAttribute(aggregate.source())),
79+
List.of(Expressions.attribute(aggregate.aggregates().getFirst())),
8180
LocalSupplier.of(
8281
new Block[] { BlockUtils.constantBlock(PlannerUtils.NON_BREAKING_BLOCK_FACTORY, null, 1) }
8382
)

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,6 +2784,24 @@ private static List<String> orderNames(TopN topN) {
27842784
return topN.order().stream().map(o -> as(o.child(), NamedExpression.class).name()).toList();
27852785
}
27862786

2787+
/**
2788+
* Expects
2789+
* Eval[[2[INTEGER] AS x]]
2790+
* \_Limit[1000[INTEGER],false]
2791+
* \_LocalRelation[[{e}#9],[ConstantNullBlock[positions=1]]]
2792+
*/
2793+
public void testEvalAfterStats() {
2794+
var plan = optimizedPlan("""
2795+
ROW foo = 1
2796+
| STATS x = max(foo)
2797+
| EVAL x = 2
2798+
""");
2799+
var eval = as(plan, Eval.class);
2800+
var limit = as(eval.child(), Limit.class);
2801+
var localRelation = as(limit.child(), LocalRelation.class);
2802+
assertThat(Expressions.names(eval.output()), contains("x"));
2803+
}
2804+
27872805
public void testCombineLimitWithOrderByThroughFilterAndEval() {
27882806
LogicalPlan plan = optimizedPlan("""
27892807
from test

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/registry/ModelRegistry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,10 @@ public void updateModelTransaction(Model newModel, Model existingModel, ActionLi
605605
format(
606606
"Failed to rollback while handling failure to update inference endpoint [%s]. "
607607
+ "Endpoint may be in an inconsistent state due to [%s]",
608-
inferenceEntityId
608+
inferenceEntityId,
609+
configResponse.buildFailureMessage()
609610
),
610-
RestStatus.INTERNAL_SERVER_ERROR,
611-
configResponse.buildFailureMessage()
611+
RestStatus.INTERNAL_SERVER_ERROR
612612
)
613613
);
614614
} else {

0 commit comments

Comments
 (0)