-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Prevent unnamed fields #127416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent unnamed fields #127416
Changes from all commits
1e9ec5d
595e946
216bdc6
4f7bd79
ebbc0b6
a1b1842
a9eed40
8e2e225
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -826,6 +826,25 @@ public List<Alias> visitFields(EsqlBaseParser.FieldsContext ctx) { | |
return ctx != null ? visitList(this, ctx.field(), Alias.class) : new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Main change |
||
public Alias visitRerankField(EsqlBaseParser.RerankFieldContext ctx) { | ||
return visitRerankField(ctx, source(ctx)); | ||
} | ||
|
||
private Alias visitRerankField(EsqlBaseParser.RerankFieldContext ctx, Source source) { | ||
UnresolvedAttribute id = visitQualifiedName(ctx.qualifiedName()); | ||
assert id != null; | ||
|
||
var boolExprCtx = ctx.booleanExpression(); | ||
Expression value = boolExprCtx == null ? id : expression(boolExprCtx); | ||
return new Alias(source, id.name(), value); | ||
} | ||
|
||
@Override | ||
public List<Alias> visitRerankFields(EsqlBaseParser.RerankFieldsContext ctx) { | ||
return ctx != null ? visitList(this, ctx.rerankField(), Alias.class) : new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public NamedExpression visitAggField(EsqlBaseParser.AggFieldContext ctx) { | ||
Source source = source(ctx); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -731,7 +731,7 @@ public PlanFactory visitRerankCommand(EsqlBaseParser.RerankCommandContext ctx) { | |
); | ||
} | ||
|
||
return p -> new Rerank(source, p, inferenceId(ctx.inferenceId), queryText, visitFields(ctx.fields())); | ||
return p -> new Rerank(source, p, inferenceId(ctx.inferenceId), queryText, visitRerankFields(ctx.rerankFields())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Main change |
||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3613,6 +3613,19 @@ public void testResolveRerankFields() { | |
assertThat(rerank.scoreAttribute(), equalTo(getAttributeByName(relation.output(), MetadataAttribute.SCORE))); | ||
} | ||
|
||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New test |
||
// Unnamed field. | ||
try { | ||
LogicalPlan plan = analyze(""" | ||
FROM books METADATA _score | ||
| WHERE title:"food" | ||
| RERANK "food" ON title, SUBSTRING(description, 0, 100), yearRenamed=year WITH `reranking-inference-id` | ||
""", "mapping-books.json"); | ||
} catch (ParsingException ex) { | ||
assertThat(ex.getMessage(), containsString("line 3:36: mismatched input '(' expecting {'=', ',', '.', 'with'}")); | ||
} | ||
} | ||
|
||
{ | ||
VerificationException ve = expectThrows( | ||
VerificationException.class, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main change