mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[ES|QL] Enables the timepicker if the time params are used with cast (#215820)](https://github.com/elastic/kibana/pull/215820) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Stratoula Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2025-03-27T15:35:20Z","message":"[ES|QL] Enables the timepicker if the time params are used with cast (#215820)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/215366\n\nChanges the utility to take under consideration the cast. (different\nrepresentation in the ast tree)\n\n<img width=\"1524\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/a85571c3-2e71-4bc7-822b-3b44d77975e5\"\n/>\n\n\n### Checklist\n\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"61c64bcaee61e81d8ee68531cf7ba45e92aba975","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:ES|QL","Team:ESQL","backport:version","v9.1.0","v8.19.0"],"title":"[ES|QL] Enables the timepicker if the time params are used with cast","number":215820,"url":"https://github.com/elastic/kibana/pull/215820","mergeCommit":{"message":"[ES|QL] Enables the timepicker if the time params are used with cast (#215820)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/215366\n\nChanges the utility to take under consideration the cast. (different\nrepresentation in the ast tree)\n\n<img width=\"1524\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/a85571c3-2e71-4bc7-822b-3b44d77975e5\"\n/>\n\n\n### Checklist\n\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"61c64bcaee61e81d8ee68531cf7ba45e92aba975"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215820","number":215820,"mergeCommit":{"message":"[ES|QL] Enables the timepicker if the time params are used with cast (#215820)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/215366\n\nChanges the utility to take under consideration the cast. (different\nrepresentation in the ast tree)\n\n<img width=\"1524\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/a85571c3-2e71-4bc7-822b-3b44d77975e5\"\n/>\n\n\n### Checklist\n\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"61c64bcaee61e81d8ee68531cf7ba45e92aba975"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
parent
ef7e92e02e
commit
02a0ac0d61
3 changed files with 30 additions and 5 deletions
|
@ -29,6 +29,7 @@ export type {
|
|||
AstProviderFn,
|
||||
EditorError,
|
||||
ESQLAstNode,
|
||||
ESQLInlineCast,
|
||||
} from './src/types';
|
||||
|
||||
export {
|
||||
|
|
|
@ -183,6 +183,14 @@ describe('esql query helpers', () => {
|
|||
)
|
||||
).toBe('event.timefield');
|
||||
});
|
||||
|
||||
it('should return the time field if the column is casted', () => {
|
||||
expect(
|
||||
getTimeFieldFromESQLQuery(
|
||||
'from a | WHERE date_nanos::date >= ?_tstart AND date_nanos::date <= ?_tend'
|
||||
)
|
||||
).toBe('date_nanos');
|
||||
});
|
||||
});
|
||||
|
||||
describe('prettifyQuery', function () {
|
||||
|
|
|
@ -13,6 +13,7 @@ import type {
|
|||
ESQLFunction,
|
||||
ESQLColumn,
|
||||
ESQLSingleAstItem,
|
||||
ESQLInlineCast,
|
||||
ESQLCommandOption,
|
||||
} from '@kbn/esql-ast';
|
||||
import type { ESQLControlVariable } from '@kbn/esql-types';
|
||||
|
@ -100,12 +101,27 @@ export const getTimeFieldFromESQLQuery = (esql: string) => {
|
|||
}
|
||||
const lowLevelFunction = allFunctionsWithNamedParams[allFunctionsWithNamedParams.length - 1];
|
||||
|
||||
const column = lowLevelFunction.args.find((arg) => {
|
||||
const argument = arg as ESQLSingleAstItem;
|
||||
return argument.type === 'column';
|
||||
}) as ESQLColumn;
|
||||
let columnName: string | undefined;
|
||||
|
||||
return column?.name;
|
||||
lowLevelFunction.args.some((arg) => {
|
||||
const argument = arg as ESQLSingleAstItem | ESQLInlineCast<ESQLSingleAstItem>;
|
||||
if (argument.type === 'column') {
|
||||
columnName = argument.name;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
argument.type === 'inlineCast' &&
|
||||
(argument as ESQLInlineCast<ESQLSingleAstItem>).value.type === 'column'
|
||||
) {
|
||||
columnName = (argument as ESQLInlineCast<ESQLSingleAstItem>).value.name;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return columnName;
|
||||
};
|
||||
|
||||
export const isQueryWrappedByPipes = (query: string): boolean => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue