@@ -5,19 +5,19 @@ import {
55 DataQueryResponse ,
66 SupplementaryQueryType ,
77 TimeRange ,
8- TypedVariableModel ,
98 toDataFrame ,
9+ TypedVariableModel ,
1010} from '@grafana/data' ;
11- import { DataQuery } from '@grafana/schema' ;
12- import { Observable , of } from 'rxjs' ;
1311import { DataSourceWithBackend } from '@grafana/runtime' ;
12+ import { DataQuery } from '@grafana/schema' ;
1413import { mockDatasource } from '__mocks__/datasource' ;
15- import { CHBuilderQuery , CHQuery , CHSqlQuery , EditorType } from 'types/sql' ;
16- import { ColumnHint , QueryType , BuilderMode , QueryBuilderOptions } from 'types/queryBuilder' ;
1714import { cloneDeep } from 'lodash' ;
15+ import { Observable , of } from 'rxjs' ;
16+ import { BuilderMode , ColumnHint , QueryBuilderOptions , QueryType } from 'types/queryBuilder' ;
17+ import { CHBuilderQuery , CHQuery , CHSqlQuery , EditorType } from 'types/sql' ;
18+ import { AdHocFilter } from './adHocFilter' ;
1819import { Datasource } from './CHDatasource' ;
1920import * as logs from './logs' ;
20- import { AdHocFilter } from './adHocFilter' ;
2121
2222jest . mock ( './logs' , ( ) => ( {
2323 getTimeFieldRoundingClause : jest . fn ( ) ,
@@ -517,6 +517,42 @@ describe('ClickHouseDatasource', () => {
517517 datasource = cloneDeep ( mockDatasource ) ;
518518 } ) ;
519519
520+ describe ( 'getSupportedSupplementaryQueryTypes' , ( ) => {
521+ it ( 'should return LogsVolume for empty dsRequest' , async ( ) => {
522+ const result = datasource . getSupportedSupplementaryQueryTypes ( ) ;
523+ expect ( result ) . toEqual ( [ SupplementaryQueryType . LogsVolume ] ) ;
524+ } ) ;
525+
526+ it ( 'should return LogsVolume when all targets use Builder editor' , async ( ) => {
527+ const dsRequest : DataQueryRequest < CHQuery > = {
528+ ...request ,
529+ targets : [
530+ {
531+ ...query ,
532+ editorType : EditorType . Builder ,
533+ } ,
534+ ] ,
535+ } ;
536+ const result = datasource . getSupportedSupplementaryQueryTypes ( dsRequest ) ;
537+ expect ( result ) . toEqual ( [ SupplementaryQueryType . LogsVolume ] ) ;
538+ } ) ;
539+
540+ it ( 'should return empty array when any target uses SQL editor' , async ( ) => {
541+ const dsRequest : DataQueryRequest < CHQuery > = {
542+ ...request ,
543+ targets : [
544+ {
545+ ...query ,
546+ editorType : EditorType . SQL ,
547+ queryType : query . builderOptions . queryType ,
548+ } ,
549+ ] ,
550+ } ;
551+ const result = datasource . getSupportedSupplementaryQueryTypes ( dsRequest ) ;
552+ expect ( result ) . toEqual ( [ ] ) ;
553+ } ) ;
554+ } ) ;
555+
520556 describe ( 'getSupplementaryLogsVolumeQuery' , ( ) => {
521557 it ( 'should return undefined if any of the conditions are not met' , async ( ) => {
522558 [ QueryType . Table , QueryType . TimeSeries , QueryType . Traces ] . forEach ( ( queryType ) => {
0 commit comments