-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into flash1293/unskip-flaky-test
- Loading branch information
Showing
180 changed files
with
2,890 additions
and
938 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
src/platform/packages/shared/kbn-esql-ast/src/mutate/commands/join/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import * as commands from '..'; | ||
import { EsqlQuery } from '../../../query'; | ||
|
||
describe('commands.where', () => { | ||
describe('.list()', () => { | ||
it('lists all "JOIN" commands', () => { | ||
const src = | ||
'FROM index | LIMIT 1 | JOIN join_index1 ON join_field1 | WHERE b == 2 | JOIN join_index2 ON join_field2 | LIMIT 1'; | ||
const query = EsqlQuery.fromSrc(src); | ||
|
||
const nodes = [...commands.join.list(query.ast)]; | ||
|
||
expect(nodes).toMatchObject([ | ||
{ | ||
type: 'command', | ||
name: 'join', | ||
args: [ | ||
{ | ||
type: 'identifier', | ||
name: 'join_index1', | ||
}, | ||
{}, | ||
], | ||
}, | ||
{ | ||
type: 'command', | ||
name: 'join', | ||
args: [ | ||
{ | ||
type: 'identifier', | ||
name: 'join_index2', | ||
}, | ||
{}, | ||
], | ||
}, | ||
]); | ||
}); | ||
}); | ||
|
||
describe('.byIndex()', () => { | ||
it('retrieves the specific "WHERE" command by index', () => { | ||
const src = | ||
'FROM index | LIMIT 1 | JOIN join_index1 ON join_field1 | WHERE b == 2 | JOIN join_index2 ON join_field2 | LIMIT 1'; | ||
const query = EsqlQuery.fromSrc(src); | ||
|
||
const node1 = commands.join.byIndex(query.ast, 1); | ||
const node2 = commands.join.byIndex(query.ast, 0); | ||
|
||
expect(node1).toMatchObject({ | ||
type: 'command', | ||
name: 'join', | ||
args: [ | ||
{ | ||
type: 'identifier', | ||
name: 'join_index2', | ||
}, | ||
{}, | ||
], | ||
}); | ||
expect(node2).toMatchObject({ | ||
type: 'command', | ||
name: 'join', | ||
args: [ | ||
{ | ||
type: 'identifier', | ||
name: 'join_index1', | ||
}, | ||
{}, | ||
], | ||
}); | ||
}); | ||
}); | ||
|
||
describe('.summarize', () => { | ||
it('returns target index fields', () => { | ||
const src = | ||
'FROM index | LIMIT 1 | JOIN join_index1 ON join_field1 | WHERE b == 2 | JOIN join_index2 ON join_field2 | LIMIT 1'; | ||
const query = EsqlQuery.fromSrc(src); | ||
const summary = commands.join.summarize(query.ast); | ||
|
||
expect(summary).toMatchObject([ | ||
{ | ||
target: { | ||
index: { | ||
type: 'identifier', | ||
name: 'join_index1', | ||
}, | ||
}, | ||
}, | ||
{ | ||
target: { | ||
index: { | ||
type: 'identifier', | ||
name: 'join_index2', | ||
}, | ||
}, | ||
}, | ||
]); | ||
}); | ||
|
||
it('returns target aliases', () => { | ||
const src = | ||
'FROM index | LIMIT 1 | JOIN join_index1 AS a ON join_field1 | WHERE b == 2 | JOIN join_index2 AS b ON join_field2 | LIMIT 1'; | ||
const query = EsqlQuery.fromSrc(src); | ||
const summary = commands.join.summarize(query.ast); | ||
|
||
expect(summary).toMatchObject([ | ||
{ | ||
target: { | ||
alias: { | ||
type: 'identifier', | ||
name: 'a', | ||
}, | ||
}, | ||
}, | ||
{ | ||
target: { | ||
alias: { | ||
type: 'identifier', | ||
name: 'b', | ||
}, | ||
}, | ||
}, | ||
]); | ||
}); | ||
|
||
it('captures join conditions', () => { | ||
const src = | ||
'FROM index | LIMIT 1 | JOIN join_index1 AS a ON join_field1 | WHERE b == 2 | JOIN join_index2 AS b ON join_field2, join_field3 | LIMIT 1'; | ||
const query = EsqlQuery.fromSrc(src); | ||
const summary = commands.join.summarize(query.ast); | ||
|
||
expect(summary).toMatchObject([ | ||
{ | ||
conditions: [ | ||
{ | ||
type: 'column', | ||
name: 'join_field1', | ||
}, | ||
], | ||
}, | ||
{ | ||
conditions: [ | ||
{ | ||
type: 'column', | ||
name: 'join_field2', | ||
}, | ||
{ | ||
type: 'column', | ||
name: 'join_field3', | ||
}, | ||
], | ||
}, | ||
]); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.