@@ -799,7 +799,7 @@ async function translateMetricChartConfig(
799
799
}
800
800
801
801
// assumes all the selects are from a single metric type, for now
802
- const { select, from, ...restChartConfig } = chartConfig ;
802
+ const { select, from, filters , where , ...restChartConfig } = chartConfig ;
803
803
if ( ! select || ! Array . isArray ( select ) ) {
804
804
throw new Error ( 'multi select or string select on metrics not supported' ) ;
805
805
}
@@ -824,6 +824,7 @@ async function translateMetricChartConfig(
824
824
tableName : metricTables [ MetricsDataType . Gauge ] ,
825
825
} ,
826
826
filters : [
827
+ ...( filters ?? [ ] ) ,
827
828
{
828
829
type : 'sql' ,
829
830
condition : `MetricName = '${ metricName } '` ,
@@ -874,6 +875,7 @@ async function translateMetricChartConfig(
874
875
databaseName : '' ,
875
876
tableName : 'Bucketed' ,
876
877
} ,
878
+ where : '' , // clear up the condition since the where clause is already applied at the upstream CTE
877
879
timestampValueExpression : timeBucketCol ,
878
880
} ;
879
881
} else if ( metricType === MetricsDataType . Sum && metricName ) {
@@ -899,6 +901,7 @@ async function translateMetricChartConfig(
899
901
tableName : metricTables [ MetricsDataType . Gauge ] ,
900
902
} ,
901
903
filters : [
904
+ ...( filters ?? [ ] ) ,
902
905
{
903
906
type : 'sql' ,
904
907
condition : `MetricName = '${ metricName } '` ,
@@ -971,6 +974,7 @@ async function translateMetricChartConfig(
971
974
databaseName : '' ,
972
975
tableName : 'Bucketed' ,
973
976
} ,
977
+ where : '' , // clear up the condition since the where clause is already applied at the upstream CTE
974
978
timestampValueExpression : `\`${ timeBucketCol } \`` ,
975
979
} ;
976
980
} else if ( metricType === MetricsDataType . Histogram && metricName ) {
@@ -995,6 +999,7 @@ async function translateMetricChartConfig(
995
999
tableName : metricTables [ MetricsDataType . Histogram ] ,
996
1000
} ,
997
1001
filters : [
1002
+ ...( filters ?? [ ] ) ,
998
1003
{
999
1004
type : 'sql' ,
1000
1005
condition : `MetricName = '${ metricName } '` ,
@@ -1059,6 +1064,7 @@ async function translateMetricChartConfig(
1059
1064
databaseName : '' ,
1060
1065
tableName : 'RawHist' ,
1061
1066
} ,
1067
+ where : '' , // clear up the condition since the where clause is already applied at the upstream CTE
1062
1068
} ;
1063
1069
}
1064
1070
0 commit comments