Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/datasource/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ export class CHDataSource
const queryProcessing = async () => {
try {
this.options = options;
const targets = options.targets.filter((target) => !target.hide && target.query);
const targets = options.targets.filter((target) => !target.hide && target.query?.trim());
return await this.executeQueries(targets, options);
} catch (error) {
console.error('Query processing failed:', error);
Expand All @@ -556,7 +556,7 @@ export class CHDataSource
queryVariables(options: DataQueryRequest<CHQuery>): any {
const queryProcessing = async () => {
this.options = options;
const targets = options.targets.filter((target) => !target.hide && target?.query || typeof target === 'string');
const targets = options.targets.filter((target) => !target.hide && (target?.query?.trim() || typeof target === 'string'));
const queries = await Promise.all(targets.map(async (target) => {
return this.createQuery(options, (typeof target === 'string') ? {query: target, datasourceMode: DatasourceMode.Variable} : target)
}));
Expand Down Expand Up @@ -710,6 +710,9 @@ export class CHDataSource
}

async metricFindQuery(query: string, options?: any) {
if (!query || !query.trim()) {
return [];
}
let interpolatedQuery: string;
const wildcardChar = '%';
const searchFilterVariableName = '__searchFilter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ export const useConnectionData = (query, datasource) => {
const querySegment = useCallback(
async (type: any) => {
let query = buildExploreQuery(type);
if (!query) {
return [];
}
try {
return await datasource.metricFindQuery(query);
} catch (error: any) {
Expand Down Expand Up @@ -191,7 +194,7 @@ export const useConnectionData = (query, datasource) => {
}, [selectedDatabase, querySegment]);

useEffect(() => {
if (!!selectedDatabase || !!selectedTable || !!selectedDateTimeType) {
if (selectedDatabase && selectedTable && selectedDateTimeType) {
(async () => {
try {
const timestampColumns = await querySegment(selectedDateTimeType);
Expand All @@ -205,7 +208,7 @@ export const useConnectionData = (query, datasource) => {
}, [selectedTable, selectedDatabase, selectedDateTimeType, querySegment]);

useEffect(() => {
if (!!selectedDatabase || !!selectedTable) {
if (selectedDatabase && selectedTable) {
(async () => {
try {
const dateColumns = await querySegment('DATE');
Expand Down
Loading