This is an automated email from the ASF dual-hosted git repository.
suneet pushed a commit to branch 0.21.0
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/0.21.0 by this push:
new bd5e64e treat null as not defined (#10751) (#10768)
bd5e64e is described below
commit bd5e64e8d503085e3de01f85322d533f949510ea
Author: Jihoon Son <[email protected]>
AuthorDate: Mon Jan 18 10:44:55 2021 -0800
treat null as not defined (#10751) (#10768)
Co-authored-by: Vadim Ogievetsky <[email protected]>
---
.../src/components/auto-form/auto-form.spec.tsx | 76 ++++++++++++++++++++++
web-console/src/components/auto-form/auto-form.tsx | 2 +-
2 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/web-console/src/components/auto-form/auto-form.spec.tsx
b/web-console/src/components/auto-form/auto-form.spec.tsx
index c2beb3d..d0e6c41 100644
--- a/web-console/src/components/auto-form/auto-form.spec.tsx
+++ b/web-console/src/components/auto-form/auto-form.spec.tsx
@@ -19,6 +19,8 @@
import { shallow } from 'enzyme';
import React from 'react';
+import { COMPACTION_CONFIG_FIELDS } from '../../druid-models';
+
import { AutoForm } from './auto-form';
describe('AutoForm', () => {
@@ -44,4 +46,78 @@ describe('AutoForm', () => {
);
expect(autoForm).toMatchSnapshot();
});
+
+ describe('.issueWithModel', () => {
+ it('should find no issue when everything is fine', () => {
+ expect(AutoForm.issueWithModel({},
COMPACTION_CONFIG_FIELDS)).toBeUndefined();
+
+ expect(
+ AutoForm.issueWithModel(
+ {
+ dataSource: 'ds',
+ taskPriority: 25,
+ inputSegmentSizeBytes: 419430400,
+ maxRowsPerSegment: null,
+ skipOffsetFromLatest: 'P4D',
+ tuningConfig: {
+ maxRowsInMemory: null,
+ maxBytesInMemory: null,
+ maxTotalRows: null,
+ splitHintSpec: null,
+ partitionsSpec: {
+ type: 'dynamic',
+ maxRowsPerSegment: 5000000,
+ maxTotalRows: null,
+ },
+ indexSpec: null,
+ indexSpecForIntermediatePersists: null,
+ maxPendingPersists: null,
+ pushTimeout: null,
+ segmentWriteOutMediumFactory: null,
+ maxNumConcurrentSubTasks: null,
+ maxRetry: null,
+ taskStatusCheckPeriodMs: null,
+ chatHandlerTimeout: null,
+ chatHandlerNumRetries: null,
+ maxNumSegmentsToMerge: null,
+ totalNumMergeTasks: null,
+ type: 'index_parallel',
+ forceGuaranteedRollup: false,
+ },
+ taskContext: null,
+ },
+ COMPACTION_CONFIG_FIELDS,
+ ),
+ ).toBeUndefined();
+ });
+ });
+
+ it('should find issue correctly', () => {
+ expect(AutoForm.issueWithModel(undefined as any,
COMPACTION_CONFIG_FIELDS)).toEqual(
+ 'model is undefined',
+ );
+
+ expect(
+ AutoForm.issueWithModel(
+ {
+ dataSource: 'ds',
+ taskPriority: 25,
+ inputSegmentSizeBytes: 419430400,
+ skipOffsetFromLatest: 'P4D',
+ tuningConfig: {
+ partitionsSpec: {
+ type: 'dynamic',
+ maxRowsPerSegment: 5000000,
+ maxTotalRows: null,
+ },
+ totalNumMergeTasks: 5,
+ type: 'index_parallel',
+ forceGuaranteedRollup: false,
+ },
+ taskContext: null,
+ },
+ COMPACTION_CONFIG_FIELDS,
+ ),
+ ).toEqual('field tuningConfig.totalNumMergeTasks is defined but it should
not be');
+ });
});
diff --git a/web-console/src/components/auto-form/auto-form.tsx
b/web-console/src/components/auto-form/auto-form.tsx
index edc948a..32dc874 100644
--- a/web-console/src/components/auto-form/auto-form.tsx
+++ b/web-console/src/components/auto-form/auto-form.tsx
@@ -122,7 +122,7 @@ export class AutoForm<T extends Record<string, any>>
extends React.PureComponent
for (const field of fields) {
const fieldValue = deepGet(model, field.name);
- const fieldValueDefined = typeof fieldValue !== 'undefined';
+ const fieldValueDefined = fieldValue != null;
const fieldThatIsDefined = definedFields[field.name];
if (fieldThatIsDefined) {
if (fieldThatIsDefined === field) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]