You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/03/30 20:48:28 UTC

[GitHub] [druid] mcbrewster opened a new pull request #9587: Use auto-form for add an edit lookups

mcbrewster opened a new pull request #9587: Use auto-form for add an edit lookups
URL: https://github.com/apache/druid/pull/9587
 
 
   <img width="661" alt="Screen Shot 2020-03-30 at 2 40 42 PM" src="https://user-images.githubusercontent.com/37322608/77960097-ef13cd00-7294-11ea-9fac-11d9bfb5734b.png">
   
   The lookup 'spec json input has been replace with an auto form the capture the type and the map for the auto form. You cannot submit a lookup unless it has a type and that the map is an object composed of key value pairs where the value is of type string. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky merged pull request #9587: Use auto-form for add an edit lookups

Posted by GitBox <gi...@apache.org>.
vogievetsky merged pull request #9587: Use auto-form for add an edit lookups
URL: https://github.com/apache/druid/pull/9587
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups
URL: https://github.com/apache/druid/pull/9587#discussion_r405281007
 
 

 ##########
 File path: web-console/src/dialogs/lookup-edit-dialog/lookup-edit-dialog.tsx
 ##########
 @@ -93,8 +194,365 @@ export const LookupEditDialog = React.memo(function LookupEditDialog(props: Look
     }
   }
 
-  const disableSubmit =
-    lookupName === '' || lookupVersion === '' || lookupTier === '' || !validJson(lookupSpec);
+  const fields = [
+    {
+      name: 'type',
+      type: 'string',
+      suggestions: ['map', 'cachedNamespace'],
+      adjustment: (model: LookupSpec) => {
+        if (model.type === 'map' && model.extractionNamespace && model.extractionNamespace.type) {
+          return model;
+        }
+        model.extractionNamespace = { type: 'uri', namespaceParseSpec: { format: 'csv' } };
+        return model;
+      },
+    },
+    {
+      name: 'map',
+      type: 'json',
+      defined: (model: LookupSpec) => {
+        return model.type === 'map';
+      },
+    },
+    {
+      name: 'extractionNamespace.type',
+      type: 'string',
+      label: 'Globally cached lookup type',
+      placeholder: 'uri',
+      suggestions: ['uri', 'jdbc'],
+      defined: (model: LookupSpec) => model.type === 'cachedNamespace',
+    },
+    {
+      name: 'extractionNamespace.uriPrefix',
+      type: 'string',
+      label: 'URI prefix',
+      info:
+        'A URI which specifies a directory (or other searchable resource) in which to search for files',
+      placeholder: 's3://bucket/some/key/prefix/',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.fileRegex',
+      type: 'string',
+      label: 'File regex',
+      placeholder: 'renames-[0-9]*\\.gz',
+      info:
+        'Optional regex for matching the file name under uriPrefix. Only used if uriPrefix is used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.format',
+      type: 'string',
+      label: 'Format',
+      defaultValue: 'csv',
+      suggestions: ['csv', 'tsv', 'customJson', 'simpleJson'],
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.columns',
+      type: 'string-array',
+      label: 'Columns',
+      placeholder: `["key", "value"]`,
+      info: 'The list of columns in the csv file',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.keyColumn',
+      type: 'string',
+      label: 'Key column',
+      placeholder: 'Key',
+      info: 'The name of the column containing the key',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.valueColumn',
+      type: 'string',
+      label: 'Value column',
+      placeholder: 'Value',
+      info: 'The name of the column containing the value',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.hasHeaderRow',
+      type: 'boolean',
+      label: 'Has header row',
+      defaultValue: false,
+      info: `A flag to indicate that column information can be extracted from the input files' header row`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.skipHeaderRows',
+      type: 'number',
+      label: 'Skip header rows',
+      placeholder: '0',
+      info: `Number of header rows to be skipped. The default number of header rows to be skipped is 0.`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.delimiter',
+      type: 'string',
+      label: 'Delimiter',
+      placeholder: `\t`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.listDelimiter',
+      type: 'string',
+      label: 'List delimiter',
+      placeholder: `\u0001`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.keyFieldName',
+      type: 'string',
+      label: 'Key field name',
+      placeholder: `key`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'customJson',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.valueFieldName',
+      type: 'string',
+      label: 'Value field name',
+      placeholder: `value`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'customJson',
+    },
+    {
+      name: 'extractionNamespace.namespace',
+      type: 'string',
+      label: 'Namespace',
+      placeholder: 'some_lookup',
+      info: (
+        <p>
+          The namespace value in the SQL query:
+          <br />
+          SELECT keyColumn, valueColumn, tsColumn? FROM <strong>namespace</strong>.table WHERE
+          filter
+        </p>
+      ),
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.createTables',
+      type: 'boolean',
+      label: 'CreateTables',
+      info: 'Defines the connectURI value on the The connector config to used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.connectURI',
+      type: 'string',
+      label: 'ConnectURI',
+      info: 'Defines the connectURI value on the The connector config to used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.user',
+      type: 'string',
+      label: 'User',
+      info: 'Defines the user too be used by the connector config',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.password',
+      type: 'string',
+      label: 'Password',
+      info: 'Defines the password too be used by the connector config',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.table',
+      type: 'string',
+      label: 'Table',
+      placeholder: 'some_lookup_table',
+      info: (
+        <p>
+          The table which contains the key value pairs. This will become the table value in the SQL
+          query:
+          <br />
+          SELECT keyColumn, valueColumn, tsColumn? FROM namespace.<strong>table</strong> WHERE
+          filter
+        </p>
 
 Review comment:
   instead of `<br>` it is better to use multiple `<p>`s like so:
   
   ```
   <>
           <p>
             The table which contains the key value pairs. This will become the table value in the SQL
             query:
             </p>
             <p>
             SELECT keyColumn, valueColumn, tsColumn? FROM namespace.<strong>table</strong> WHERE
             filter
           </p>
   </>
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups
URL: https://github.com/apache/druid/pull/9587#discussion_r405116898
 
 

 ##########
 File path: web-console/src/dialogs/lookup-edit-dialog/lookup-edit-dialog.tsx
 ##########
 @@ -93,8 +136,45 @@ export const LookupEditDialog = React.memo(function LookupEditDialog(props: Look
     }
   }
 
-  const disableSubmit =
-    lookupName === '' || lookupVersion === '' || lookupTier === '' || !validJson(lookupSpec);
+  let disableSubmit =
+    lookupName === '' ||
+    lookupVersion === '' ||
+    lookupTier === '' ||
+    lookupSpec.type === '' ||
+    lookupSpec.type === undefined ||
+    (lookupSpec.type === 'map' && lookupSpec.map === undefined) ||
+    (lookupSpec.type === 'cachedNamespace' && lookupSpec.extractionNamespace === undefined);
+
+  if (!disableSubmit && lookupSpec.type === 'cachedNamespace' && lookupSpec.extractionNamespace) {
+    const namespaceParseSpec = lookupSpec.extractionNamespace.namespaceParseSpec;
 
 Review comment:
   can you extract his whole check into a function please?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on issue #9587: Use auto-form for add an edit lookups

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on issue #9587: Use auto-form for add an edit lookups
URL: https://github.com/apache/druid/pull/9587#issuecomment-611247242
 
 
   Thank you for responding to all the feedback!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] lgtm-com[bot] commented on issue #9587: Use auto-form for add an edit lookups

Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on issue #9587: Use auto-form for add an edit lookups
URL: https://github.com/apache/druid/pull/9587#issuecomment-606245934
 
 
   This pull request **introduces 1 alert** when merging 4c3385b14dc889983a946b0aee94d09ab4de4b30 into fa5da6693ca4dbb614c6398e50e34b772298f5ae - [view on LGTM.com](https://lgtm.com/projects/g/apache/druid/rev/pr-bc78e261d8d9a9f5b481ecdc37519e9ba03a2a36)
   
   **new alerts:**
   
   * 1 for Unreachable statement

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups
URL: https://github.com/apache/druid/pull/9587#discussion_r405279936
 
 

 ##########
 File path: web-console/src/dialogs/lookup-edit-dialog/lookup-edit-dialog.tsx
 ##########
 @@ -93,8 +194,365 @@ export const LookupEditDialog = React.memo(function LookupEditDialog(props: Look
     }
   }
 
-  const disableSubmit =
-    lookupName === '' || lookupVersion === '' || lookupTier === '' || !validJson(lookupSpec);
+  const fields = [
+    {
+      name: 'type',
+      type: 'string',
+      suggestions: ['map', 'cachedNamespace'],
+      adjustment: (model: LookupSpec) => {
+        if (model.type === 'map' && model.extractionNamespace && model.extractionNamespace.type) {
+          return model;
+        }
+        model.extractionNamespace = { type: 'uri', namespaceParseSpec: { format: 'csv' } };
+        return model;
+      },
+    },
+    {
+      name: 'map',
+      type: 'json',
+      defined: (model: LookupSpec) => {
+        return model.type === 'map';
+      },
+    },
+    {
+      name: 'extractionNamespace.type',
+      type: 'string',
+      label: 'Globally cached lookup type',
+      placeholder: 'uri',
+      suggestions: ['uri', 'jdbc'],
+      defined: (model: LookupSpec) => model.type === 'cachedNamespace',
+    },
+    {
+      name: 'extractionNamespace.uriPrefix',
+      type: 'string',
+      label: 'URI prefix',
+      info:
+        'A URI which specifies a directory (or other searchable resource) in which to search for files',
+      placeholder: 's3://bucket/some/key/prefix/',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.fileRegex',
+      type: 'string',
+      label: 'File regex',
+      placeholder: 'renames-[0-9]*\\.gz',
+      info:
+        'Optional regex for matching the file name under uriPrefix. Only used if uriPrefix is used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.format',
+      type: 'string',
+      label: 'Format',
+      defaultValue: 'csv',
+      suggestions: ['csv', 'tsv', 'customJson', 'simpleJson'],
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.columns',
+      type: 'string-array',
+      label: 'Columns',
+      placeholder: `["key", "value"]`,
+      info: 'The list of columns in the csv file',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.keyColumn',
+      type: 'string',
+      label: 'Key column',
+      placeholder: 'Key',
+      info: 'The name of the column containing the key',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.valueColumn',
+      type: 'string',
+      label: 'Value column',
+      placeholder: 'Value',
+      info: 'The name of the column containing the value',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.hasHeaderRow',
+      type: 'boolean',
+      label: 'Has header row',
+      defaultValue: false,
+      info: `A flag to indicate that column information can be extracted from the input files' header row`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.skipHeaderRows',
+      type: 'number',
+      label: 'Skip header rows',
+      placeholder: '0',
+      info: `Number of header rows to be skipped. The default number of header rows to be skipped is 0.`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.delimiter',
+      type: 'string',
+      label: 'Delimiter',
+      placeholder: `\t`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.listDelimiter',
+      type: 'string',
+      label: 'List delimiter',
+      placeholder: `\u0001`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.keyFieldName',
+      type: 'string',
+      label: 'Key field name',
+      placeholder: `key`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'customJson',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.valueFieldName',
+      type: 'string',
+      label: 'Value field name',
+      placeholder: `value`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'customJson',
+    },
+    {
+      name: 'extractionNamespace.namespace',
+      type: 'string',
+      label: 'Namespace',
+      placeholder: 'some_lookup',
+      info: (
+        <p>
+          The namespace value in the SQL query:
+          <br />
+          SELECT keyColumn, valueColumn, tsColumn? FROM <strong>namespace</strong>.table WHERE
+          filter
+        </p>
+      ),
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.createTables',
+      type: 'boolean',
+      label: 'CreateTables',
+      info: 'Defines the connectURI value on the The connector config to used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.connectURI',
+      type: 'string',
+      label: 'ConnectURI',
+      info: 'Defines the connectURI value on the The connector config to used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.user',
+      type: 'string',
+      label: 'User',
+      info: 'Defines the user too be used by the connector config',
 
 Review comment:
   typo: `to`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups
URL: https://github.com/apache/druid/pull/9587#discussion_r405281463
 
 

 ##########
 File path: web-console/src/dialogs/lookup-edit-dialog/lookup-edit-dialog.tsx
 ##########
 @@ -93,8 +194,365 @@ export const LookupEditDialog = React.memo(function LookupEditDialog(props: Look
     }
   }
 
-  const disableSubmit =
-    lookupName === '' || lookupVersion === '' || lookupTier === '' || !validJson(lookupSpec);
+  const fields = [
+    {
+      name: 'type',
+      type: 'string',
+      suggestions: ['map', 'cachedNamespace'],
+      adjustment: (model: LookupSpec) => {
+        if (model.type === 'map' && model.extractionNamespace && model.extractionNamespace.type) {
+          return model;
+        }
+        model.extractionNamespace = { type: 'uri', namespaceParseSpec: { format: 'csv' } };
+        return model;
+      },
+    },
+    {
+      name: 'map',
+      type: 'json',
+      defined: (model: LookupSpec) => {
+        return model.type === 'map';
+      },
+    },
+    {
+      name: 'extractionNamespace.type',
+      type: 'string',
+      label: 'Globally cached lookup type',
+      placeholder: 'uri',
+      suggestions: ['uri', 'jdbc'],
+      defined: (model: LookupSpec) => model.type === 'cachedNamespace',
+    },
+    {
+      name: 'extractionNamespace.uriPrefix',
+      type: 'string',
+      label: 'URI prefix',
+      info:
+        'A URI which specifies a directory (or other searchable resource) in which to search for files',
+      placeholder: 's3://bucket/some/key/prefix/',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.fileRegex',
+      type: 'string',
+      label: 'File regex',
+      placeholder: 'renames-[0-9]*\\.gz',
+      info:
+        'Optional regex for matching the file name under uriPrefix. Only used if uriPrefix is used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.format',
+      type: 'string',
+      label: 'Format',
+      defaultValue: 'csv',
+      suggestions: ['csv', 'tsv', 'customJson', 'simpleJson'],
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.columns',
+      type: 'string-array',
+      label: 'Columns',
+      placeholder: `["key", "value"]`,
+      info: 'The list of columns in the csv file',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.keyColumn',
+      type: 'string',
+      label: 'Key column',
+      placeholder: 'Key',
+      info: 'The name of the column containing the key',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.valueColumn',
+      type: 'string',
+      label: 'Value column',
+      placeholder: 'Value',
+      info: 'The name of the column containing the value',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.hasHeaderRow',
+      type: 'boolean',
+      label: 'Has header row',
+      defaultValue: false,
+      info: `A flag to indicate that column information can be extracted from the input files' header row`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.skipHeaderRows',
+      type: 'number',
+      label: 'Skip header rows',
+      placeholder: '0',
+      info: `Number of header rows to be skipped. The default number of header rows to be skipped is 0.`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.delimiter',
+      type: 'string',
+      label: 'Delimiter',
+      placeholder: `\t`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.listDelimiter',
+      type: 'string',
+      label: 'List delimiter',
+      placeholder: `\u0001`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.keyFieldName',
+      type: 'string',
+      label: 'Key field name',
+      placeholder: `key`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'customJson',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.valueFieldName',
+      type: 'string',
+      label: 'Value field name',
+      placeholder: `value`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'customJson',
+    },
+    {
+      name: 'extractionNamespace.namespace',
+      type: 'string',
+      label: 'Namespace',
+      placeholder: 'some_lookup',
+      info: (
+        <p>
+          The namespace value in the SQL query:
+          <br />
+          SELECT keyColumn, valueColumn, tsColumn? FROM <strong>namespace</strong>.table WHERE
+          filter
+        </p>
+      ),
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.createTables',
+      type: 'boolean',
+      label: 'CreateTables',
+      info: 'Defines the connectURI value on the The connector config to used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.connectURI',
+      type: 'string',
+      label: 'ConnectURI',
+      info: 'Defines the connectURI value on the The connector config to used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.user',
+      type: 'string',
+      label: 'User',
+      info: 'Defines the user too be used by the connector config',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.password',
+      type: 'string',
+      label: 'Password',
+      info: 'Defines the password too be used by the connector config',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.table',
+      type: 'string',
+      label: 'Table',
+      placeholder: 'some_lookup_table',
+      info: (
+        <p>
+          The table which contains the key value pairs. This will become the table value in the SQL
+          query:
+          <br />
+          SELECT keyColumn, valueColumn, tsColumn? FROM namespace.<strong>table</strong> WHERE
+          filter
+        </p>
+      ),
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.keyColumn',
+      type: 'string',
+      label: 'Key column',
+      placeholder: 'my_key_value',
+      info: (
+        <p>
+          The column in the table which contains the keys. This will become the keyColumn value in
+          the SQL query:
+          <br />
+          SELECT <strong>keyColumn</strong>, valueColumn, tsColumn? FROM namespace.table WHERE
+          filter
+        </p>
+      ),
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.valueColumn',
+      type: 'string',
+      label: 'Value column',
+      placeholder: 'my_column_value',
+      info: (
+        <p>
+          The column in table which contains the values. This will become the valueColumn value in
+          the SQL query:
+          <br />
+          SELECT keyColumn, <strong>valueColumn</strong>, tsColumn? FROM namespace.table WHERE
+          filter
+        </p>
+      ),
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.filter',
+      type: 'string',
+      label: 'Filter',
 
 Review comment:
   add a placeholder of `'(optional)'` that is the convention that I've been using in several places.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups
URL: https://github.com/apache/druid/pull/9587#discussion_r405280023
 
 

 ##########
 File path: web-console/src/dialogs/lookup-edit-dialog/lookup-edit-dialog.tsx
 ##########
 @@ -93,8 +194,365 @@ export const LookupEditDialog = React.memo(function LookupEditDialog(props: Look
     }
   }
 
-  const disableSubmit =
-    lookupName === '' || lookupVersion === '' || lookupTier === '' || !validJson(lookupSpec);
+  const fields = [
+    {
+      name: 'type',
+      type: 'string',
+      suggestions: ['map', 'cachedNamespace'],
+      adjustment: (model: LookupSpec) => {
+        if (model.type === 'map' && model.extractionNamespace && model.extractionNamespace.type) {
+          return model;
+        }
+        model.extractionNamespace = { type: 'uri', namespaceParseSpec: { format: 'csv' } };
+        return model;
+      },
+    },
+    {
+      name: 'map',
+      type: 'json',
+      defined: (model: LookupSpec) => {
+        return model.type === 'map';
+      },
+    },
+    {
+      name: 'extractionNamespace.type',
+      type: 'string',
+      label: 'Globally cached lookup type',
+      placeholder: 'uri',
+      suggestions: ['uri', 'jdbc'],
+      defined: (model: LookupSpec) => model.type === 'cachedNamespace',
+    },
+    {
+      name: 'extractionNamespace.uriPrefix',
+      type: 'string',
+      label: 'URI prefix',
+      info:
+        'A URI which specifies a directory (or other searchable resource) in which to search for files',
+      placeholder: 's3://bucket/some/key/prefix/',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.fileRegex',
+      type: 'string',
+      label: 'File regex',
+      placeholder: 'renames-[0-9]*\\.gz',
+      info:
+        'Optional regex for matching the file name under uriPrefix. Only used if uriPrefix is used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.format',
+      type: 'string',
+      label: 'Format',
+      defaultValue: 'csv',
+      suggestions: ['csv', 'tsv', 'customJson', 'simpleJson'],
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.columns',
+      type: 'string-array',
+      label: 'Columns',
+      placeholder: `["key", "value"]`,
+      info: 'The list of columns in the csv file',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.keyColumn',
+      type: 'string',
+      label: 'Key column',
+      placeholder: 'Key',
+      info: 'The name of the column containing the key',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.valueColumn',
+      type: 'string',
+      label: 'Value column',
+      placeholder: 'Value',
+      info: 'The name of the column containing the value',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.hasHeaderRow',
+      type: 'boolean',
+      label: 'Has header row',
+      defaultValue: false,
+      info: `A flag to indicate that column information can be extracted from the input files' header row`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.skipHeaderRows',
+      type: 'number',
+      label: 'Skip header rows',
+      placeholder: '0',
+      info: `Number of header rows to be skipped. The default number of header rows to be skipped is 0.`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+          model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.delimiter',
+      type: 'string',
+      label: 'Delimiter',
+      placeholder: `\t`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.listDelimiter',
+      type: 'string',
+      label: 'List delimiter',
+      placeholder: `\u0001`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.keyFieldName',
+      type: 'string',
+      label: 'Key field name',
+      placeholder: `key`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'customJson',
+    },
+    {
+      name: 'extractionNamespace.namespaceParseSpec.valueFieldName',
+      type: 'string',
+      label: 'Value field name',
+      placeholder: `value`,
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'uri' &&
+        model.extractionNamespace.namespaceParseSpec &&
+        model.extractionNamespace.namespaceParseSpec.format === 'customJson',
+    },
+    {
+      name: 'extractionNamespace.namespace',
+      type: 'string',
+      label: 'Namespace',
+      placeholder: 'some_lookup',
+      info: (
+        <p>
+          The namespace value in the SQL query:
+          <br />
+          SELECT keyColumn, valueColumn, tsColumn? FROM <strong>namespace</strong>.table WHERE
+          filter
+        </p>
+      ),
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.createTables',
+      type: 'boolean',
+      label: 'CreateTables',
+      info: 'Defines the connectURI value on the The connector config to used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.connectURI',
+      type: 'string',
+      label: 'ConnectURI',
+      info: 'Defines the connectURI value on the The connector config to used',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.user',
+      type: 'string',
+      label: 'User',
+      info: 'Defines the user too be used by the connector config',
+      defined: (model: LookupSpec) =>
+        model.type === 'cachedNamespace' &&
+        !!model.extractionNamespace &&
+        model.extractionNamespace.type === 'jdbc',
+    },
+    {
+      name: 'extractionNamespace.connectorConfig.password',
+      type: 'string',
+      label: 'Password',
+      info: 'Defines the password too be used by the connector config',
 
 Review comment:
   Ditto

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #9587: Use auto-form for add an edit lookups
URL: https://github.com/apache/druid/pull/9587#discussion_r405115366
 
 

 ##########
 File path: web-console/src/dialogs/lookup-edit-dialog/lookup-edit-dialog.tsx
 ##########
 @@ -124,34 +202,302 @@ export const LookupEditDialog = React.memo(function LookupEditDialog(props: Look
           }
         />
       </FormGroup>
-
-      <FormGroup className="lookup-label" label="Spec:" />
-
-      <AceEditor
-        className="lookup-edit-dialog-textarea"
-        mode="hjson"
-        theme="solarized_dark"
-        onChange={(e: any) => onChange('lookupEditSpec', e)}
-        fontSize={12}
-        height="40vh"
-        width="auto"
-        showPrintMargin={false}
-        showGutter={false}
-        value={lookupSpec}
-        editorProps={{ $blockScrolling: Infinity }}
-        setOptions={{
-          tabSize: 2,
+      <AutoForm
+        fields={[
+          {
+            name: 'type',
+            type: 'string',
+            suggestions: ['map', 'cachedNamespace'],
+            adjustment: model => {
+              if (
+                model.type === 'map' &&
+                model.extractionNamespace &&
+                model.extractionNamespace.type
+              ) {
+                return model;
+              }
+              model.extractionNamespace = { type: 'uri', namespaceParseSpec: { format: 'csv' } };
+              return model;
+            },
+          },
+          {
+            name: 'map',
+            type: 'json',
+            defined: model => {
+              return model.type === 'map';
+            },
+          },
+          {
+            name: 'extractionNamespace.type',
+            type: 'string',
+            label: 'Globally cached lookup type',
+            placeholder: 'uri',
+            suggestions: ['uri', 'jdbc'],
+            defined: model => model.type === 'cachedNamespace',
+          },
+          {
+            name: 'extractionNamespace.uriPrefix',
+            type: 'string',
+            label: 'URI prefix',
+            info:
+              'A URI which specifies a directory (or other searchable resource) in which to search for files',
+            placeholder: 's3://bucket/some/key/prefix/',
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri',
+          },
+          {
+            name: 'extractionNamespace.fileRegex',
+            type: 'string',
+            label: 'File regex',
+            placeholder: 'renames-[0-9]*\\.gz',
+            info:
+              'Optional regex for matching the file name under uriPrefix. Only used if uriPrefix is used',
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri',
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.format',
+            type: 'string',
+            label: 'Format',
+            defaultValue: 'csv',
+            suggestions: ['csv', 'tsv', 'customJson', 'simpleJson'],
+            // todo needs info
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri',
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.columns',
+            type: 'string-array',
+            label: 'Columns',
+            placeholder: `["key", "value"]`,
+            info: 'The list of columns in the csv file',
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+                model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.keyColumn',
+            type: 'string',
+            label: 'Key column',
+            placeholder: 'Key',
+            info: 'The name of the column containing the key',
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+                model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.valueColumn',
+            type: 'string',
+            label: 'Value column',
+            placeholder: 'Value',
+            info: 'The name of the column containing the value',
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+                model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.hasHeaderRow',
+            type: 'boolean',
+            label: 'Has header row',
+            defaultValue: false,
+            info: `A flag to indicate that column information can be extracted from the input files' header row`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+                model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.skipHeaderRows',
+            type: 'number',
+            label: 'Skip header rows',
+            placeholder: '0',
+            info: `Number of header rows to be skipped`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+                model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.delimiter',
+            type: 'string',
+            label: 'Delimiter',
+            placeholder: `\t`,
+            info: `The delimiter in the file`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.listDelimiter',
+            type: 'string',
+            label: 'List delimiter',
+            placeholder: `\u0001`,
+            info: `The list delimiter in the file\t`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.keyFieldName',
+            type: 'string',
+            label: 'Key field name',
+            placeholder: `key`,
+            info: `The field name of the key`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              model.extractionNamespace.namespaceParseSpec.format === 'customJson',
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.valueFieldName',
+            type: 'string',
+            label: 'Value field name',
+            placeholder: `value`,
+            info: `The field name of the value`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              model.extractionNamespace.namespaceParseSpec.format === 'customJson',
+          },
+          {
+            name: 'extractionNamespace.namespace',
+            type: 'string',
+            label: 'Namespace',
+            placeholder: 'some_lookup',
+            info: `The namespace to define`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.table',
+            type: 'string',
+            label: 'Table',
+            placeholder: 'some_lookup_table',
+            info: `The table which contains the key value pairs`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.keyColumn',
+            type: 'string',
+            label: 'Key column',
+            placeholder: 'the_old_dim_value',
+            info: `The column in table which contains the keys`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.valueColumn',
+            type: 'string',
+            label: 'Value column',
+            placeholder: 'the_new_dim_value',
+            info: `The column in table which contains the values`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.filter',
+            type: 'json',
+            label: 'Filter',
+            info: `The filter to use when selecting lookups, this is used to create a where clause on lookup population`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.tsColumn',
+            type: 'string',
+            label: 'TsColumn',
+            info: `The column in table which contains when the key was updated`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.pollPeriod',
+            type: 'string',
+            label: 'Poll Period',
 
 Review comment:
   caps?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org