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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]