From 9a85c4a557ea1a70438f897055dfe41c2ea38d09 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 27 Apr 2023 13:58:15 -0400 Subject: [PATCH] [8.7] [ML] Fix retention policy date field should list destination index date fields (#155765) (#156047) # Backport This will backport the following commits from `main` to `8.7`: - [[ML] Fix retention policy date field should list destination index date fields (#155765)](https://github.com/elastic/kibana/pull/155765) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Quynh Nguyen (Quinn) <43350163+qn895@users.noreply.github.com> --- .../step_details/step_details_form.tsx | 6 ++-- .../apps/transform/edit_clone/cloning.ts | 31 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx index bc3f6b7fc5009..4254be3279d87 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx @@ -278,7 +278,9 @@ export const StepDetailsForm: FC = React.memo( // Reset retention policy settings when the user disables the whole option useEffect(() => { if (!isRetentionPolicyEnabled) { - setRetentionPolicyDateField(isRetentionPolicyAvailable ? dateFieldNames[0] : ''); + setRetentionPolicyDateField( + isRetentionPolicyAvailable ? dataViewAvailableTimeFields[0] : '' + ); setRetentionPolicyMaxAge(''); } // eslint-disable-next-line react-hooks/exhaustive-deps @@ -713,7 +715,7 @@ export const StepDetailsForm: FC = React.memo( )} > ({ text }))} + options={dataViewAvailableTimeFields.map((text: string) => ({ text }))} value={retentionPolicyDateField} onChange={(e) => setRetentionPolicyDateField(e.target.value)} data-test-subj="transformRetentionPolicyDateFieldSelect" diff --git a/x-pack/test/functional/apps/transform/edit_clone/cloning.ts b/x-pack/test/functional/apps/transform/edit_clone/cloning.ts index 6b3bbac3f7b3d..152ea8c9caa66 100644 --- a/x-pack/test/functional/apps/transform/edit_clone/cloning.ts +++ b/x-pack/test/functional/apps/transform/edit_clone/cloning.ts @@ -35,12 +35,19 @@ function getTransformConfig(): TransformPivotConfig { source: { index: ['ft_ecommerce'] }, pivot: { group_by: { category: { terms: { field: 'category.keyword' } } }, - aggregations: { 'products.base_price.avg': { avg: { field: 'products.base_price' } } }, + aggregations: { + 'products.base_price.avg': { avg: { field: 'products.base_price' } }, + 'order_date.max': { + max: { + field: 'order_date', + }, + }, + }, }, description: 'ecommerce batch transform with avg(products.base_price) grouped by terms(category)', frequency: '3s', - retention_policy: { time: { field: 'order_date', max_age: '1d' } }, + retention_policy: { time: { field: 'order_date.max', max_age: '1d' } }, settings: { max_page_search_size: 250, num_failure_retries: 0, @@ -75,11 +82,16 @@ function getTransformConfigWithRuntimeMappings(): TransformPivotConfig { 'rt_total_charge.avg': { avg: { field: 'rt_total_charge' } }, 'rt_total_charge.min': { min: { field: 'rt_total_charge' } }, 'rt_total_charge.max': { max: { field: 'rt_total_charge' } }, + max_order_date: { + max: { + field: 'order_date', + }, + }, }, }, description: 'ecommerce batch transform grouped by terms(rt_gender_lower)', frequency: '3s', - retention_policy: { time: { field: 'order_date', max_age: '3d' } }, + retention_policy: { time: { field: 'max_order_date', max_age: '3d' } }, settings: { max_page_search_size: 250, num_failure_retries: 5, @@ -155,11 +167,16 @@ function getTransformConfigWithBoolFilterAgg(): TransformPivotConfig { }, }, }, + max_order_date: { + max: { + field: 'order_date', + }, + }, }, }, description: 'ecommerce batch transform with filter aggregations', frequency: '3s', - retention_policy: { time: { field: 'order_date', max_age: '3d' } }, + retention_policy: { time: { field: 'max_order_date', max_age: '3d' } }, settings: { max_page_search_size: 250, num_failure_retries: 5, @@ -253,7 +270,7 @@ export default function ({ getService }: FtrProviderContext) { ], }, retentionPolicySwitchEnabled: true, - retentionPolicyField: 'order_date', + retentionPolicyField: 'order_date.max', retentionPolicyMaxAge: '1d', numFailureRetries: getNumFailureRetriesStr( transformConfigWithPivot.settings?.num_failure_retries @@ -288,7 +305,7 @@ export default function ({ getService }: FtrProviderContext) { values: [`female`, `male`], }, retentionPolicySwitchEnabled: true, - retentionPolicyField: 'order_date', + retentionPolicyField: 'max_order_date', retentionPolicyMaxAge: '3d', numFailureRetries: getNumFailureRetriesStr( transformConfigWithRuntimeMapping.settings?.num_failure_retries @@ -341,7 +358,7 @@ export default function ({ getService }: FtrProviderContext) { ], }, retentionPolicySwitchEnabled: true, - retentionPolicyField: 'order_date', + retentionPolicyField: 'max_order_date', retentionPolicyMaxAge: '3d', numFailureRetries: getNumFailureRetriesStr( transformConfigWithBoolFilterAgg.settings?.num_failure_retries