@@ -930,14 +930,16 @@ func TestParseSeriesByTagWithCostsFromCountTable(t *testing.T) {
930930
931931func TestTaggedFinder_whereFilter (t * testing.T ) {
932932 tests := []struct {
933- name string
934- query string
935- from int64
936- until int64
937- dailyEnabled bool
938- taggedCosts map [string ]* config.Costs
939- want string
940- wantPre string
933+ name string
934+ query string
935+ from int64
936+ until int64
937+ dailyEnabled bool
938+ useCarbonBehavior bool
939+ dontMatchMissingTags bool
940+ taggedCosts map [string ]* config.Costs
941+ want string
942+ wantPre string
941943 }{
942944 {
943945 name : "nodaily" ,
@@ -959,26 +961,41 @@ func TestTaggedFinder_whereFilter(t *testing.T) {
959961 date .FromTimestampToDaysFormat (1668124800 ) + "' AND Date <= '" + date .UntilTimestampToDaysFormat (1668124810 ) + "')" ,
960962 wantPre : "" ,
961963 },
964+ {
965+ name : "" ,
966+ query : "seriesByTag('emptyval=', 'what=value')" ,
967+ from : 1668124800 , // 2022-11-11 00:00:00 UTC
968+ until : 1668124810 , // 2022-11-11 00:00:10 UTC
969+ dailyEnabled : true ,
970+ useCarbonBehavior : true ,
971+ want : "((Tag1='what=value') AND (NOT arrayExists((x) -> x LIKE 'emptyval=%', Tags))) AND (Date >='" +
972+ date .FromTimestampToDaysFormat (1668124800 ) + "' AND Date <= '" + date .UntilTimestampToDaysFormat (1668124810 ) + "')" ,
973+ wantPre : "" ,
974+ },
962975 }
963976 for _ , tt := range tests {
964977 t .Run (tt .name + " " + time .Unix (tt .from , 0 ).Format (time .RFC3339 ), func (t * testing.T ) {
965978 config := config .New ()
966979 config .ClickHouse .TaggedCosts = tt .taggedCosts
967- terms , err := ParseSeriesByTag (tt .query , config )
968- if err != nil {
969- t .Fatal (err )
970- }
980+ config .FeatureFlags .UseCarbonBehavior = tt .useCarbonBehavior
981+ config .FeatureFlags .DontMatchMissingTags = tt .dontMatchMissingTags
982+
971983 f := NewTagged (
972984 "http://localhost:8123/" ,
973985 "graphite_tags" ,
974986 "" ,
975987 tt .dailyEnabled ,
976- false ,
977- false ,
988+ tt . useCarbonBehavior ,
989+ tt . dontMatchMissingTags ,
978990 false ,
979991 clickhouse.Options {},
980992 tt .taggedCosts ,
981993 )
994+ stat := & FinderStat {}
995+ terms , err := f .PrepareTaggedTerms (context .Background (), config , tt .query , tt .from , tt .until , stat )
996+ if err != nil {
997+ t .Fatal (err )
998+ }
982999 got , gotDate , err := f .whereFilter (terms , tt .from , tt .until )
9831000 if err != nil {
9841001 t .Fatal (err )
0 commit comments