You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by cw...@apache.org on 2019/07/20 05:59:15 UTC
[incubator-druid] branch master updated: Web console: cleanup build,
check licenses in test (#8113)
This is an automated email from the ASF dual-hosted git repository.
cwylie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git
The following commit(s) were added to refs/heads/master by this push:
new 2b2fcc0 Web console: cleanup build, check licenses in test (#8113)
2b2fcc0 is described below
commit 2b2fcc0371a8d7002d58f1bd997ea03f383dee14
Author: Vadim Ogievetsky <va...@gmail.com>
AuthorDate: Fri Jul 19 22:59:07 2019 -0700
Web console: cleanup build, check licenses in test (#8113)
* cleanup build, check licenses
* cleanup filterMap type
* don't run license check twice
---
web-console/README.md | 1 +
web-console/package.json | 1 -
web-console/src/utils/druid-type.ts | 8 +++----
web-console/src/utils/general.tsx | 4 ++--
web-console/src/utils/ingestion-spec.tsx | 26 ++++++++++++++++------
.../load-data-view/filter-table/filter-table.tsx | 2 +-
.../parse-data-table/parse-data-table.tsx | 4 ++--
.../parse-time-table/parse-time-table.tsx | 4 ++--
.../load-data-view/schema-table/schema-table.tsx | 2 +-
.../transform-table/transform-table.tsx | 4 ++--
web-console/tsconfig.json | 4 +---
11 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/web-console/README.md b/web-console/README.md
index 3cec6bb..0d8c7a4 100644
--- a/web-console/README.md
+++ b/web-console/README.md
@@ -40,6 +40,7 @@ As part of this repo:
- `lib/` - A place where some overrides to the react-table stylus files live, this is outside of the normal SCSS build system.
- `old-console/` - Files for the overlord console
- `public/` - The compiled destination of the file powering this console
+- `assets/` - The images (and other assets) used within the console
- `script/` - Some helper bash scripts for running this console
- `src/` - This directory (together with `lib`) constitutes all the source code for this console
diff --git a/web-console/package.json b/web-console/package.json
index 7a9b23f..7dc5408 100644
--- a/web-console/package.json
+++ b/web-console/package.json
@@ -35,7 +35,6 @@
"scripts": {
"compile": "./script/build",
"pretest": "./script/build",
- "run": "./script/run",
"test": "npm run tslint && npm run stylelint && jest --silent 2>&1",
"coverage": "jest --coverage",
"update-snapshots": "jest -u",
diff --git a/web-console/src/utils/druid-type.ts b/web-console/src/utils/druid-type.ts
index a103659..955c8a2 100644
--- a/web-console/src/utils/druid-type.ts
+++ b/web-console/src/utils/druid-type.ts
@@ -51,10 +51,10 @@ export function getDimensionSpecs(
hasRollup: boolean,
): (string | DimensionSpec)[] {
return filterMap(headerAndRows.header, h => {
- if (h === '__time') return null;
+ if (h === '__time') return;
const guessedType = getColumnTypeFromHeaderAndRows(headerAndRows, h);
if (guessedType === 'string') return h;
- if (hasRollup) return null;
+ if (hasRollup) return;
return {
type: guessedType,
name: h,
@@ -65,7 +65,7 @@ export function getDimensionSpecs(
export function getMetricSecs(headerAndRows: HeaderAndRows): MetricSpec[] {
return [{ name: 'count', type: 'count' }].concat(
filterMap(headerAndRows.header, h => {
- if (h === '__time') return null;
+ if (h === '__time') return;
const guessedType = getColumnTypeFromHeaderAndRows(headerAndRows, h);
switch (guessedType) {
case 'double':
@@ -73,7 +73,7 @@ export function getMetricSecs(headerAndRows: HeaderAndRows): MetricSpec[] {
case 'long':
return { name: `sum_${h}`, type: 'longSum', fieldName: h };
default:
- return null;
+ return;
}
}),
);
diff --git a/web-console/src/utils/general.tsx b/web-console/src/utils/general.tsx
index 6f834e8..ef75edc 100644
--- a/web-console/src/utils/general.tsx
+++ b/web-console/src/utils/general.tsx
@@ -276,8 +276,8 @@ export function parseStringToJSON(s: string): JSON | null {
}
}
-export function filterMap<T, Q>(xs: T[], f: (x: T, i?: number) => Q | null | undefined): Q[] {
- return (xs.map(f) as any).filter(Boolean);
+export function filterMap<T, Q>(xs: T[], f: (x: T, i: number) => Q | undefined): Q[] {
+ return xs.map(f).filter((x: Q | undefined) => typeof x !== 'undefined') as Q[];
}
export function alphanumericCompare(a: string, b: string): number {
diff --git a/web-console/src/utils/ingestion-spec.tsx b/web-console/src/utils/ingestion-spec.tsx
index c31e12b..f39ceaa 100644
--- a/web-console/src/utils/ingestion-spec.tsx
+++ b/web-console/src/utils/ingestion-spec.tsx
@@ -1292,12 +1292,19 @@ export function getIoConfigTuningFormFields(
// ---------------------------------------
-function filenameFromPath(path: string | undefined): string | null {
- if (!path) return null;
+function filterIsFilename(filter: string): boolean {
+ return !/[*?]/.test(filter);
+}
+
+function filenameFromPath(path: string): string | null {
const m = path.match(/([^\/.]+)[^\/]*?\/?$/);
return m ? m[1] : null;
}
+function basenameFromFilename(filename: string): string | null {
+ return filename.split('.')[0] || null;
+}
+
export function fillDataSourceName(spec: IngestionSpec): IngestionSpec {
const ioConfig = deepGet(spec, 'ioConfig');
if (!ioConfig) return spec;
@@ -1315,15 +1322,20 @@ export function guessDataSourceName(ioConfig: IoConfig): string | null {
switch (firehose.type) {
case 'local':
- return filenameFromPath(firehose.baseDir);
+ if (firehose.filter && filterIsFilename(firehose.filter)) {
+ return basenameFromFilename(firehose.filter);
+ } else if (firehose.baseDir) {
+ return filenameFromPath(firehose.baseDir);
+ } else {
+ return null;
+ }
case 'static-s3':
- return filenameFromPath(
- (firehose.uris || EMPTY_ARRAY)[0] || (firehose.prefixes || EMPTY_ARRAY)[0],
- );
+ const s3Path = (firehose.uris || EMPTY_ARRAY)[0] || (firehose.prefixes || EMPTY_ARRAY)[0];
+ return s3Path ? filenameFromPath(s3Path) : null;
case 'http':
- return filenameFromPath(firehose.uris ? firehose.uris[0] : undefined);
+ return Array.isArray(firehose.uris) ? filenameFromPath(firehose.uris[0]) : null;
}
return null;
diff --git a/web-console/src/views/load-data-view/filter-table/filter-table.tsx b/web-console/src/views/load-data-view/filter-table/filter-table.tsx
index 25756f7..5fde4f8 100644
--- a/web-console/src/views/load-data-view/filter-table/filter-table.tsx
+++ b/web-console/src/views/load-data-view/filter-table/filter-table.tsx
@@ -52,7 +52,7 @@ export class FilterTable extends React.PureComponent<FilterTableProps> {
className="filter-table -striped -highlight"
data={sampleData.rows}
columns={filterMap(sampleData.header, (columnName, i) => {
- if (!caseInsensitiveContains(columnName, columnFilter)) return null;
+ if (!caseInsensitiveContains(columnName, columnFilter)) return;
const timestamp = columnName === '__time';
const filterIndex = dimensionFilters.findIndex(f => f.dimension === columnName);
const filter = dimensionFilters[filterIndex];
diff --git a/web-console/src/views/load-data-view/parse-data-table/parse-data-table.tsx b/web-console/src/views/load-data-view/parse-data-table/parse-data-table.tsx
index b30d08b..9a47216 100644
--- a/web-console/src/views/load-data-view/parse-data-table/parse-data-table.tsx
+++ b/web-console/src/views/load-data-view/parse-data-table/parse-data-table.tsx
@@ -53,9 +53,9 @@ export class ParseDataTable extends React.PureComponent<ParseDataTableProps> {
className="parse-data-table -striped -highlight"
data={sampleData.rows}
columns={filterMap(sampleData.header, (columnName, i) => {
- if (!caseInsensitiveContains(columnName, columnFilter)) return null;
+ if (!caseInsensitiveContains(columnName, columnFilter)) return;
const flattenFieldIndex = flattenFields.findIndex(f => f.name === columnName);
- if (flattenFieldIndex === -1 && flattenedColumnsOnly) return null;
+ if (flattenFieldIndex === -1 && flattenedColumnsOnly) return;
const flattenField = flattenFields[flattenFieldIndex];
return {
Header: (
diff --git a/web-console/src/views/load-data-view/parse-time-table/parse-time-table.tsx b/web-console/src/views/load-data-view/parse-time-table/parse-time-table.tsx
index 4a8c3e1..f2a79ca 100644
--- a/web-console/src/views/load-data-view/parse-time-table/parse-time-table.tsx
+++ b/web-console/src/views/load-data-view/parse-time-table/parse-time-table.tsx
@@ -62,14 +62,14 @@ export class ParseTimeTable extends React.PureComponent<ParseTimeTableProps> {
headerAndRows.header.length ? headerAndRows.header : ['__error__'],
(columnName, i) => {
const timestamp = columnName === '__time';
- if (!timestamp && !caseInsensitiveContains(columnName, columnFilter)) return null;
+ if (!timestamp && !caseInsensitiveContains(columnName, columnFilter)) return;
const selected = timestampSpec.column === columnName;
const possibleFormat = timestamp
? null
: possibleDruidFormatForValues(
filterMap(headerAndRows.rows, d => (d.parsed ? d.parsed[columnName] : null)),
);
- if (possibleTimestampColumnsOnly && !timestamp && !possibleFormat) return null;
+ if (possibleTimestampColumnsOnly && !timestamp && !possibleFormat) return;
const columnClassName = classNames({
timestamp,
diff --git a/web-console/src/views/load-data-view/schema-table/schema-table.tsx b/web-console/src/views/load-data-view/schema-table/schema-table.tsx
index aac4e56..fbbaefa 100644
--- a/web-console/src/views/load-data-view/schema-table/schema-table.tsx
+++ b/web-console/src/views/load-data-view/schema-table/schema-table.tsx
@@ -75,7 +75,7 @@ export class SchemaTable extends React.PureComponent<SchemaTableProps> {
className="schema-table -striped -highlight"
data={headerAndRows.rows}
columns={filterMap(dimensionMetricSortedHeader, (columnName, i) => {
- if (!caseInsensitiveContains(columnName, columnFilter)) return null;
+ if (!caseInsensitiveContains(columnName, columnFilter)) return;
const metricSpecIndex = metricsSpec.findIndex(m => getMetricSpecName(m) === columnName);
const metricSpec = metricsSpec[metricSpecIndex];
diff --git a/web-console/src/views/load-data-view/transform-table/transform-table.tsx b/web-console/src/views/load-data-view/transform-table/transform-table.tsx
index 36e721e..50c3e01 100644
--- a/web-console/src/views/load-data-view/transform-table/transform-table.tsx
+++ b/web-console/src/views/load-data-view/transform-table/transform-table.tsx
@@ -53,10 +53,10 @@ export class TransformTable extends React.PureComponent<TransformTableProps> {
className="transform-table -striped -highlight"
data={sampleData.rows}
columns={filterMap(sampleData.header, (columnName, i) => {
- if (!caseInsensitiveContains(columnName, columnFilter)) return null;
+ if (!caseInsensitiveContains(columnName, columnFilter)) return;
const timestamp = columnName === '__time';
const transformIndex = transforms.findIndex(f => f.name === columnName);
- if (transformIndex === -1 && transformedColumnsOnly) return null;
+ if (transformIndex === -1 && transformedColumnsOnly) return;
const transform = transforms[transformIndex];
const columnClassName = classNames({
diff --git a/web-console/tsconfig.json b/web-console/tsconfig.json
index 697bd76..0e43c57 100644
--- a/web-console/tsconfig.json
+++ b/web-console/tsconfig.json
@@ -18,9 +18,7 @@
"moduleResolution": "node",
"lib": ["dom", "es2016"],
"jsx": "react",
- "rootDirs": ["lib", "src"],
-
- "outDir": "build"
+ "rootDirs": ["lib", "src"]
},
"include": ["src/**/*.ts", "src/**/*.tsx", "lib/sql-function-doc.ts"]
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org