Skip to content
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

[8.x] [ES|QL] Fix param parsing in qualified name (#203801) #203822

Merged
merged 1 commit into from
Dec 11, 2024
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 @@ -141,6 +141,35 @@ describe('commands', () => {
]);
});

it('KEEP (with param)', () => {
const query = 'FROM index | KEEP abc, ?param';
const { ast } = parse(query);

expect(ast).toMatchObject([
{},
{
type: 'command',
name: 'keep',
args: [
{
type: 'column',
name: 'abc',
},
{
type: 'column',
args: [
{
type: 'literal',
literalType: 'param',
value: 'param',
},
],
},
],
},
]);
});

it('SORT', () => {
const query = 'FROM index | SORT 1';
const { ast } = parse(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,21 @@ export function createColumn(ctx: ParserRuleContext): ESQLColumn {
if (ctx instanceof QualifiedNamePatternContext) {
const list = ctx.identifierPattern_list();

for (const identifier of list) {
const name = parseIdentifier(identifier.getText());
const node = Builder.identifier({ name }, createParserFields(identifier));
for (const identifierPattern of list) {
const ID_PATTERN = identifierPattern.ID_PATTERN();

args.push(node);
if (ID_PATTERN) {
const name = parseIdentifier(ID_PATTERN.getText());
const node = Builder.identifier({ name }, createParserFields(identifierPattern));

args.push(node);
} else {
const parameter = createParam(identifierPattern.parameter());

if (parameter) {
args.push(parameter);
}
}
}
} else if (ctx instanceof QualifiedNameContext) {
const list = ctx.identifierOrParameter_list();
Expand Down
Loading