mirror of https://github.com/apache/druid.git
Web console: fix datasource name auto detection (#8479)
* fix datasource name guessing * fix comment
This commit is contained in:
parent
fd58fbc8d3
commit
b8dc6a94b3
|
@ -1456,16 +1456,15 @@ function basenameFromFilename(filename: string): string | undefined {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fillDataSourceNameIfNeeded(spec: IngestionSpec): IngestionSpec {
|
export function fillDataSourceNameIfNeeded(spec: IngestionSpec): IngestionSpec {
|
||||||
// Do not overwrite if the spec already has a name
|
const possibleName = guessDataSourceName(spec);
|
||||||
if (deepGet(spec, 'dataSchema.dataSource')) return spec;
|
|
||||||
const ioConfig = deepGet(spec, 'ioConfig');
|
|
||||||
if (!ioConfig) return spec;
|
|
||||||
const possibleName = guessDataSourceName(ioConfig);
|
|
||||||
if (!possibleName) return spec;
|
if (!possibleName) return spec;
|
||||||
return deepSet(spec, 'dataSchema.dataSource', possibleName);
|
return deepSet(spec, 'dataSchema.dataSource', possibleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function guessDataSourceName(ioConfig: IoConfig): string | undefined {
|
export function guessDataSourceName(spec: IngestionSpec): string | undefined {
|
||||||
|
const ioConfig = deepGet(spec, 'ioConfig');
|
||||||
|
if (!ioConfig) return;
|
||||||
|
|
||||||
switch (ioConfig.type) {
|
switch (ioConfig.type) {
|
||||||
case 'index':
|
case 'index':
|
||||||
case 'index_parallel':
|
case 'index_parallel':
|
||||||
|
|
|
@ -36,7 +36,7 @@ import {
|
||||||
} from './ingestion-spec';
|
} from './ingestion-spec';
|
||||||
import { deepGet, deepSet, whitelistKeys } from './object-change';
|
import { deepGet, deepSet, whitelistKeys } from './object-change';
|
||||||
|
|
||||||
const MS_IN_HALF_HOUR = 30 * 60 * 1000;
|
const MS_IN_HOUR = 60 * 60 * 1000;
|
||||||
|
|
||||||
const SAMPLER_URL = `/druid/indexer/v1/sampler`;
|
const SAMPLER_URL = `/druid/indexer/v1/sampler`;
|
||||||
const BASE_SAMPLER_CONFIG: SamplerConfig = {
|
const BASE_SAMPLER_CONFIG: SamplerConfig = {
|
||||||
|
@ -199,8 +199,8 @@ export async function scopeDownIngestSegmentFirehoseIntervalIfNeeded(
|
||||||
const end = new Date(intervalParts[1]);
|
const end = new Date(intervalParts[1]);
|
||||||
if (isNaN(end.valueOf())) throw new Error(`could not decode interval end`);
|
if (isNaN(end.valueOf())) throw new Error(`could not decode interval end`);
|
||||||
|
|
||||||
// Less than or equal to 1/2 hour so there is no need to adjust intervals
|
// Less than or equal to 1 hour so there is no need to adjust intervals
|
||||||
if (Math.abs(end.valueOf() - start.valueOf()) <= MS_IN_HALF_HOUR) return ioConfig;
|
if (Math.abs(end.valueOf() - start.valueOf()) <= MS_IN_HOUR) return ioConfig;
|
||||||
|
|
||||||
const dataSourceMetadataResponse = await queryDruidRune({
|
const dataSourceMetadataResponse = await queryDruidRune({
|
||||||
queryType: 'dataSourceMetadata',
|
queryType: 'dataSourceMetadata',
|
||||||
|
@ -218,7 +218,7 @@ export async function scopeDownIngestSegmentFirehoseIntervalIfNeeded(
|
||||||
if (maxIngestedEventTime < start) return ioConfig;
|
if (maxIngestedEventTime < start) return ioConfig;
|
||||||
|
|
||||||
const newEnd = maxIngestedEventTime < end ? maxIngestedEventTime : end;
|
const newEnd = maxIngestedEventTime < end ? maxIngestedEventTime : end;
|
||||||
const newStart = new Date(newEnd.valueOf() - MS_IN_HALF_HOUR); // Set start to 1/2hr ago
|
const newStart = new Date(newEnd.valueOf() - MS_IN_HOUR); // Set start to 1 hour ago
|
||||||
|
|
||||||
return deepSet(
|
return deepSet(
|
||||||
ioConfig,
|
ioConfig,
|
||||||
|
|
Loading…
Reference in New Issue