Skip to content

Commit 21ec77c

Browse files
committed
better error msg
1 parent 12876e0 commit 21ec77c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@ public PlanFactory visitEnrichCommand(EsqlBaseParser.EnrichCommandContext ctx) {
445445
public PlanFactory visitChangePointCommand(EsqlBaseParser.ChangePointCommandContext ctx) {
446446
Source src = source(ctx);
447447
NamedExpression value = visitQualifiedName(ctx.value);
448-
NamedExpression key = ctx.key == null ? new UnresolvedAttribute(src, "@timestamp") : visitQualifiedName(ctx.key);
448+
NamedExpression key = ctx.key == null
449+
? new UnresolvedAttribute(src, "@timestamp", "Key column unspecified and default [@timestamp] is missing")
450+
: visitQualifiedName(ctx.key);
449451
Attribute targetType = new ReferenceAttribute(
450452
src,
451453
ctx.targetType == null ? "type" : visitQualifiedName(ctx.targetType).name(),

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -2021,8 +2021,10 @@ public void testChangePoint() {
20212021
var airports = AnalyzerTestUtils.analyzer(loadMapping("mapping-airports.json", "airports"));
20222022
assertEquals("1:30: Unknown column [blahblah]", error("FROM airports | CHANGE_POINT blahblah ON scalerank", airports));
20232023
assertEquals("1:43: Unknown column [blahblah]", error("FROM airports | CHANGE_POINT scalerank ON blahblah", airports));
2024-
// TODO: nicer error message for missing default column "@timestamp"
2025-
assertEquals("1:17: Unknown column [@timestamp]", error("FROM airports | CHANGE_POINT scalerank", airports));
2024+
assertEquals(
2025+
"1:17: Key column unspecified and default [@timestamp] is missing",
2026+
error("FROM airports | CHANGE_POINT scalerank", airports)
2027+
);
20262028
}
20272029

20282030
public void testChangePoint_keySortable() {

0 commit comments

Comments
 (0)