From acb5124679e8aa1541ab168d60d8ab9d3527e76f Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Thu, 29 Feb 2024 15:45:58 -0800 Subject: [PATCH] make double detection better (#15998) --- .../druid-models/ingestion-spec/ingestion-spec.spec.ts | 1 + .../src/druid-models/ingestion-spec/ingestion-spec.tsx | 4 +++- .../input-format-step/input-format-step.tsx | 9 ++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/web-console/src/druid-models/ingestion-spec/ingestion-spec.spec.ts b/web-console/src/druid-models/ingestion-spec/ingestion-spec.spec.ts index 86787010f27..d6513aa2081 100644 --- a/web-console/src/druid-models/ingestion-spec/ingestion-spec.spec.ts +++ b/web-console/src/druid-models/ingestion-spec/ingestion-spec.spec.ts @@ -720,6 +720,7 @@ describe('spec utils', () => { expect(guessColumnTypeFromInput([null, 1, 2.1, 3], true)).toEqual('double'); expect(guessColumnTypeFromInput([null, '1', '2.1', '3'], false)).toEqual('string'); expect(guessColumnTypeFromInput([null, '1', '2.1', '3'], true)).toEqual('double'); + expect(guessColumnTypeFromInput([null, '1.0', '2.0', '3.0'], true)).toEqual('double'); }); it('works for ARRAY', () => { diff --git a/web-console/src/druid-models/ingestion-spec/ingestion-spec.tsx b/web-console/src/druid-models/ingestion-spec/ingestion-spec.tsx index 81aaf3b3633..5a751af2011 100644 --- a/web-console/src/druid-models/ingestion-spec/ingestion-spec.tsx +++ b/web-console/src/druid-models/ingestion-spec/ingestion-spec.tsx @@ -2588,7 +2588,9 @@ function isIntegerOrNull(x: any): boolean { function isIntegerOrNullAcceptString(x: any): boolean { return ( - x == null || ((typeof x === 'number' || typeof x === 'string') && Number.isInteger(Number(x))) + x == null || + (typeof x === 'number' && Number.isInteger(x)) || + (typeof x === 'string' && !x.includes('.') && Number.isInteger(Number(x))) ); } diff --git a/web-console/src/views/workbench-view/input-format-step/input-format-step.tsx b/web-console/src/views/workbench-view/input-format-step/input-format-step.tsx index 9729b224831..cfe51d8fc3d 100644 --- a/web-console/src/views/workbench-view/input-format-step/input-format-step.tsx +++ b/web-console/src/views/workbench-view/input-format-step/input-format-step.tsx @@ -193,6 +193,9 @@ export const InputFormatStep = React.memo(function InputFormatStep(props: InputF inputSourceAndFormat.inputSource, ); + const needsResample = inputSourceAndFormatToSample !== inputSourceAndFormat; + const nextDisabled = !inputSourceFormatAndMore || needsResample; + return (
@@ -246,7 +249,7 @@ export const InputFormatStep = React.memo(function InputFormatStep(props: InputF onChange={setInputSourceAndFormat as any} /> )} - {inputSourceAndFormatToSample !== inputSourceAndFormat && ( + {needsResample && (