Skip to content

Commit

Permalink
Merge branch 'main' into enable-roles-space-serverless
Browse files Browse the repository at this point in the history
  • Loading branch information
jeramysoucy authored Oct 14, 2024
2 parents e72cf08 + 08715c6 commit 3dc49a4
Show file tree
Hide file tree
Showing 4 changed files with 355 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,263 @@ const greatestDefinition: FunctionDefinition = {
examples: ['ROW a = 10, b = 20\n| EVAL g = GREATEST(a, b)'],
};

// Do not edit this manually... generated by scripts/generate_function_definitions.ts
const hypotDefinition: FunctionDefinition = {
type: 'eval',
name: 'hypot',
description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.hypot', {
defaultMessage:
'Returns the hypotenuse of two numbers. The input can be any numeric values, the return value is always a double.\nHypotenuses of infinities are null.',
}),
alias: undefined,
signatures: [
{
params: [
{
name: 'number1',
type: 'double',
optional: false,
},
{
name: 'number2',
type: 'double',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'double',
optional: false,
},
{
name: 'number2',
type: 'integer',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'double',
optional: false,
},
{
name: 'number2',
type: 'long',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'double',
optional: false,
},
{
name: 'number2',
type: 'unsigned_long',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'integer',
optional: false,
},
{
name: 'number2',
type: 'double',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'integer',
optional: false,
},
{
name: 'number2',
type: 'integer',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'integer',
optional: false,
},
{
name: 'number2',
type: 'long',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'integer',
optional: false,
},
{
name: 'number2',
type: 'unsigned_long',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'long',
optional: false,
},
{
name: 'number2',
type: 'double',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'long',
optional: false,
},
{
name: 'number2',
type: 'integer',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'long',
optional: false,
},
{
name: 'number2',
type: 'long',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'long',
optional: false,
},
{
name: 'number2',
type: 'unsigned_long',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'unsigned_long',
optional: false,
},
{
name: 'number2',
type: 'double',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'unsigned_long',
optional: false,
},
{
name: 'number2',
type: 'integer',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'unsigned_long',
optional: false,
},
{
name: 'number2',
type: 'long',
optional: false,
},
],
returnType: 'double',
},
{
params: [
{
name: 'number1',
type: 'unsigned_long',
optional: false,
},
{
name: 'number2',
type: 'unsigned_long',
optional: false,
},
],
returnType: 'double',
},
],
supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'],
supportedOptions: ['by'],
validate: undefined,
examples: ['ROW a = 3.0, b = 4.0\n| EVAL c = HYPOT(a, b)'],
};

// Do not edit this manually... generated by scripts/generate_function_definitions.ts
const ipPrefixDefinition: FunctionDefinition = {
type: 'eval',
Expand Down Expand Up @@ -8811,6 +9068,7 @@ export const scalarFunctionDefinitions = [
floorDefinition,
fromBase64Definition,
greatestDefinition,
hypotDefinition,
ipPrefixDefinition,
leastDefinition,
leftDefinition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,40 @@ export const functions = {
| EVAL g = GREATEST(a, b)
\`\`\`
Note: When run on \`keyword\` or \`text\` fields, this returns the last string in alphabetical order. When run on \`boolean\` columns this will return \`true\` if any values are \`true\`.
`,
description:
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
ignoreTag: true,
}
)}
/>
),
},
// Do not edit manually... automatically generated by scripts/generate_esql_docs.ts
{
label: i18n.translate('languageDocumentation.documentationESQL.hypot', {
defaultMessage: 'HYPOT',
}),
description: (
<Markdown
openLinksInNewTab
readOnly
enableSoftLineBreaks
markdownContent={i18n.translate(
'languageDocumentation.documentationESQL.hypot.markdown',
{
defaultMessage: `<!--
This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
-->
### HYPOT
Returns the hypotenuse of two numbers. The input can be any numeric values, the return value is always a double.
Hypotenuses of infinities are null.
\`\`\`
ROW a = 3.0, b = 4.0
| EVAL c = HYPOT(a, b)
\`\`\`
`,
description:
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import React from 'react';
import { mountWithIntl as mount } from '@kbn/test-jest-helpers';
import { render, screen } from '@testing-library/react';
import { EuiButtonGroupProps, EuiButtonGroup } from '@elastic/eui';
import { DataDimensionEditor } from './dimension_editor';
import { FramePublicAPI, DatasourcePublicAPI } from '../../../types';
Expand Down Expand Up @@ -195,6 +196,65 @@ describe('XY Config panels', () => {

expect(component.find(EuiColorPicker).prop('color')).toEqual('red');
});
test.each<{ collapseFn?: string; shouldDisplay?: boolean }>([
// should display color picker
{ shouldDisplay: true },
// should not display color picker
{ collapseFn: 'sum', shouldDisplay: false },
])(
'should only show color picker when collapseFn is defined for breakdown group',
({ collapseFn = undefined, shouldDisplay = true }) => {
const state = {
...testState(),
layers: [
{
collapseFn,
seriesType: 'bar',
layerType: LayerTypes.DATA,
layerId: 'first',
splitAccessor: 'breakdownAccessor',
xAccessor: 'foo',
accessors: ['bar'],
yConfig: [{ forAccessor: 'bar', color: 'red' }],
},
],
} as XYState;

render(
<DataDimensionEditor
layerId={state.layers[0].layerId}
frame={{
...frame,
activeData: {
first: {
type: 'datatable',
columns: [],
rows: [{ bar: 123 }],
},
},
}}
setState={jest.fn()}
accessor="breakdownAccessor"
groupId={'breakdown'}
state={state}
formatFactory={jest.fn()}
paletteService={chartPluginMock.createPaletteRegistry()}
panelRef={React.createRef()}
addLayer={jest.fn()}
removeLayer={jest.fn()}
datasource={{} as DatasourcePublicAPI}
isDarkMode={false}
/>
);
const colorPickerUi = screen.queryByLabelText('Edit colors');

if (shouldDisplay) {
expect(colorPickerUi).toBeInTheDocument();
} else {
expect(colorPickerUi).not.toBeInTheDocument();
}
}
);
test('does not apply incorrect color', () => {
jest.useFakeTimers();
const setState = jest.fn();
Expand Down
Loading

0 comments on commit 3dc49a4

Please sign in to comment.