mirror of https://github.com/apache/druid.git
make double detection better (#15998)
This commit is contained in:
parent
c5b032799c
commit
acb5124679
|
@ -720,6 +720,7 @@ describe('spec utils', () => {
|
||||||
expect(guessColumnTypeFromInput([null, 1, 2.1, 3], true)).toEqual('double');
|
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'], false)).toEqual('string');
|
||||||
expect(guessColumnTypeFromInput([null, '1', '2.1', '3'], true)).toEqual('double');
|
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<string>', () => {
|
it('works for ARRAY<string>', () => {
|
||||||
|
|
|
@ -2588,7 +2588,9 @@ function isIntegerOrNull(x: any): boolean {
|
||||||
|
|
||||||
function isIntegerOrNullAcceptString(x: any): boolean {
|
function isIntegerOrNullAcceptString(x: any): boolean {
|
||||||
return (
|
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)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,9 @@ export const InputFormatStep = React.memo(function InputFormatStep(props: InputF
|
||||||
inputSourceAndFormat.inputSource,
|
inputSourceAndFormat.inputSource,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const needsResample = inputSourceAndFormatToSample !== inputSourceAndFormat;
|
||||||
|
const nextDisabled = !inputSourceFormatAndMore || needsResample;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="input-format-step">
|
<div className="input-format-step">
|
||||||
<div className="preview">
|
<div className="preview">
|
||||||
|
@ -246,7 +249,7 @@ export const InputFormatStep = React.memo(function InputFormatStep(props: InputF
|
||||||
onChange={setInputSourceAndFormat as any}
|
onChange={setInputSourceAndFormat as any}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{inputSourceAndFormatToSample !== inputSourceAndFormat && (
|
{needsResample && (
|
||||||
<FormGroup className="control-buttons">
|
<FormGroup className="control-buttons">
|
||||||
<Button
|
<Button
|
||||||
text="Preview changes"
|
text="Preview changes"
|
||||||
|
@ -283,7 +286,7 @@ export const InputFormatStep = React.memo(function InputFormatStep(props: InputF
|
||||||
text={altText}
|
text={altText}
|
||||||
rightIcon={IconNames.ARROW_TOP_RIGHT}
|
rightIcon={IconNames.ARROW_TOP_RIGHT}
|
||||||
minimal
|
minimal
|
||||||
disabled={!inputSourceFormatAndMore}
|
disabled={nextDisabled}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!inputSourceFormatAndMore) return;
|
if (!inputSourceFormatAndMore) return;
|
||||||
onAltSet(inputSourceFormatAndMore);
|
onAltSet(inputSourceFormatAndMore);
|
||||||
|
@ -299,7 +302,7 @@ export const InputFormatStep = React.memo(function InputFormatStep(props: InputF
|
||||||
text={doneButton ? 'Done' : 'Next'}
|
text={doneButton ? 'Done' : 'Next'}
|
||||||
rightIcon={doneButton ? IconNames.TICK : IconNames.ARROW_RIGHT}
|
rightIcon={doneButton ? IconNames.TICK : IconNames.ARROW_RIGHT}
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
disabled={!inputSourceFormatAndMore}
|
disabled={nextDisabled}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!inputSourceFormatAndMore) return;
|
if (!inputSourceFormatAndMore) return;
|
||||||
onSet(inputSourceFormatAndMore);
|
onSet(inputSourceFormatAndMore);
|
||||||
|
|
Loading…
Reference in New Issue