make double detection better (#15998)

This commit is contained in:
Vadim Ogievetsky 2024-02-29 15:45:58 -08:00 committed by GitHub
parent c5b032799c
commit acb5124679
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 4 deletions

View File

@ -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<string>', () => {

View File

@ -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)))
);
}

View File

@ -193,6 +193,9 @@ export const InputFormatStep = React.memo(function InputFormatStep(props: InputF
inputSourceAndFormat.inputSource,
);
const needsResample = inputSourceAndFormatToSample !== inputSourceAndFormat;
const nextDisabled = !inputSourceFormatAndMore || needsResample;
return (
<div className="input-format-step">
<div className="preview">
@ -246,7 +249,7 @@ export const InputFormatStep = React.memo(function InputFormatStep(props: InputF
onChange={setInputSourceAndFormat as any}
/>
)}
{inputSourceAndFormatToSample !== inputSourceAndFormat && (
{needsResample && (
<FormGroup className="control-buttons">
<Button
text="Preview changes"
@ -283,7 +286,7 @@ export const InputFormatStep = React.memo(function InputFormatStep(props: InputF
text={altText}
rightIcon={IconNames.ARROW_TOP_RIGHT}
minimal
disabled={!inputSourceFormatAndMore}
disabled={nextDisabled}
onClick={() => {
if (!inputSourceFormatAndMore) return;
onAltSet(inputSourceFormatAndMore);
@ -299,7 +302,7 @@ export const InputFormatStep = React.memo(function InputFormatStep(props: InputF
text={doneButton ? 'Done' : 'Next'}
rightIcon={doneButton ? IconNames.TICK : IconNames.ARROW_RIGHT}
intent={Intent.PRIMARY}
disabled={!inputSourceFormatAndMore}
disabled={nextDisabled}
onClick={() => {
if (!inputSourceFormatAndMore) return;
onSet(inputSourceFormatAndMore);