This is an automated email from the ASF dual-hosted git repository.
amatya pushed a commit to branch 27.0.0
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/27.0.0 by this push:
new c20212b418 Web console: fix service view filtering on other bugs
(#14597) (#14658)
c20212b418 is described below
commit c20212b4180918d25d84d131e95295e5646ff413
Author: AmatyaAvadhanula <[email protected]>
AuthorDate: Tue Jul 25 19:01:55 2023 +0530
Web console: fix service view filtering on other bugs (#14597) (#14658)
* fix service view filter
* MSQ choose best timeformat also
Co-authored-by: Vadim Ogievetsky <[email protected]>
---
web-console/src/console-application.tsx | 2 +-
web-console/src/druid-models/time/time.ts | 12 ++++++++++++
web-console/src/views/load-data-view/load-data-view.tsx | 13 ++-----------
.../workbench-view/input-format-step/input-format-step.tsx | 12 +++++++-----
4 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/web-console/src/console-application.tsx
b/web-console/src/console-application.tsx
index 9215d65b7c..807a71225f 100644
--- a/web-console/src/console-application.tsx
+++ b/web-console/src/console-application.tsx
@@ -397,7 +397,7 @@ export class ConsoleApplication extends React.PureComponent<
'services',
<ServicesView
filters={stringToTableFilters(p.match.params.filters)}
- onFiltersChange={viewFilterChange('tasks')}
+ onFiltersChange={viewFilterChange('services')}
goToQuery={this.goToQuery}
capabilities={capabilities}
/>,
diff --git a/web-console/src/druid-models/time/time.ts
b/web-console/src/druid-models/time/time.ts
index 8443f08888..8b4e1adc45 100644
--- a/web-console/src/druid-models/time/time.ts
+++ b/web-console/src/druid-models/time/time.ts
@@ -91,3 +91,15 @@ export function possibleDruidFormatForValues(values: any[]):
string | undefined
return values.every(value => timeFormatMatches(format, value));
});
}
+
+export function chooseByBestTimestamp<T extends { column: string; format:
string }>(
+ candidates: T[],
+): T | undefined {
+ return (
+ candidates.find(ts => ts.column === '__time') || // If there is a __time
column, just pick it
+ candidates.find(ts => /time/i.test(ts.column) &&
!NUMERIC_TIME_FORMATS.includes(ts.format)) || // Prefer a suggestion that has
"time" in the name and is not a numeric format
+ candidates.find(ts => /time/i.test(ts.column)) || // Otherwise anything
that has "time" in the name
+ candidates.find(ts => !NUMERIC_TIME_FORMATS.includes(ts.format)) || // Use
a suggestion that is not numeric
+ candidates[0]
+ );
+}
diff --git a/web-console/src/views/load-data-view/load-data-view.tsx
b/web-console/src/views/load-data-view/load-data-view.tsx
index 9dbf6e6eb7..df927079be 100644
--- a/web-console/src/views/load-data-view/load-data-view.tsx
+++ b/web-console/src/views/load-data-view/load-data-view.tsx
@@ -74,6 +74,7 @@ import {
adjustForceGuaranteedRollup,
adjustId,
BATCH_INPUT_FORMAT_FIELDS,
+ chooseByBestTimestamp,
cleanSpec,
computeFlattenPathsForData,
CONSTANT_TIMESTAMP_SPEC,
@@ -114,7 +115,6 @@ import {
MAX_INLINE_DATA_LENGTH,
METRIC_SPEC_FIELDS,
normalizeSpec,
- NUMERIC_TIME_FORMATS,
possibleDruidFormatForValues,
PRIMARY_PARTITION_RELATED_FORM_FIELDS,
removeTimestampTransform,
@@ -279,16 +279,7 @@ function getTimestampSpec(sampleResponse: SampleResponse |
null): TimestampSpec
},
);
- return (
- // Prefer a suggestion that has "time" in the name and is not a numeric
format
- timestampSpecs.find(
- ts => /time/i.test(ts.column) &&
!NUMERIC_TIME_FORMATS.includes(ts.format),
- ) ||
- timestampSpecs.find(ts => /time/i.test(ts.column)) || // Otherwise
anything that has "time" in the name
- timestampSpecs.find(ts => !NUMERIC_TIME_FORMATS.includes(ts.format)) || //
Use a suggestion that is not numeric
- timestampSpecs[0] || // Fall back to the first one
- CONSTANT_TIMESTAMP_SPEC // Ok, empty it is...
- );
+ return chooseByBestTimestamp(timestampSpecs) || CONSTANT_TIMESTAMP_SPEC;
}
type Step =
diff --git
a/web-console/src/views/workbench-view/input-format-step/input-format-step.tsx
b/web-console/src/views/workbench-view/input-format-step/input-format-step.tsx
index 0de752f901..7e5064867a 100644
---
a/web-console/src/views/workbench-view/input-format-step/input-format-step.tsx
+++
b/web-console/src/views/workbench-view/input-format-step/input-format-step.tsx
@@ -26,6 +26,7 @@ import { AutoForm, CenterMessage, LearnMore, Loader } from
'../../../components'
import type { InputFormat, InputSource } from '../../../druid-models';
import {
BATCH_INPUT_FORMAT_FIELDS,
+ chooseByBestTimestamp,
DETECTION_TIMESTAMP_SPEC,
guessColumnTypeFromSampleResponse,
guessIsArrayFromSampleResponse,
@@ -40,7 +41,6 @@ import {
deepSet,
EMPTY_ARRAY,
filterMap,
- findMap,
timeFormatToSql,
} from '../../../utils';
import type { SampleResponse, SampleSpec } from '../../../utils/sampler';
@@ -58,6 +58,7 @@ export interface InputFormatAndMore {
interface PossibleTimeExpression {
column: string;
+ format: string;
timeExpression: SqlExpression;
}
@@ -116,9 +117,8 @@ export const InputFormatStep = React.memo(function
InputFormatStep(props: InputF
let possibleTimeExpression: PossibleTimeExpression | undefined;
if (previewSampleResponse) {
- possibleTimeExpression = findMap(
- getHeaderNamesFromSampleResponse(previewSampleResponse),
- column => {
+ possibleTimeExpression = chooseByBestTimestamp(
+ filterMap(getHeaderNamesFromSampleResponse(previewSampleResponse),
column => {
const values = filterMap(previewSampleResponse.data, d =>
d.input?.[column]);
const possibleDruidFormat = possibleDruidFormatForValues(values);
if (!possibleDruidFormat) return;
@@ -127,6 +127,7 @@ export const InputFormatStep = React.memo(function
InputFormatStep(props: InputF
if (column === TIME_COLUMN) {
return {
column,
+ format: '',
timeExpression: C(column),
};
}
@@ -136,9 +137,10 @@ export const InputFormatStep = React.memo(function
InputFormatStep(props: InputF
return {
column,
+ format: possibleDruidFormat,
timeExpression: formatSql.fillPlaceholders([C(column)]),
};
- },
+ }),
);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]