From 9ce11dea2924b2d30d89507193527949341ebc31 Mon Sep 17 00:00:00 2001 From: Shamcle Ren Date: Tue, 21 Nov 2023 21:19:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20unify-query=20trac?= =?UTF-8?q?e=20=E6=89=93=E7=82=B9=20#1010158081115225233=20(#60)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/unify-query/query/infos/infos.go | 12 ++++++---- pkg/unify-query/query/structured/query_ts.go | 23 +++++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/pkg/unify-query/query/infos/infos.go b/pkg/unify-query/query/infos/infos.go index 47f88298a..4001dd8d7 100644 --- a/pkg/unify-query/query/infos/infos.go +++ b/pkg/unify-query/query/infos/infos.go @@ -320,10 +320,14 @@ func makeInfluxQLList( return nil, err } if len(condition) != 0 { - whereList.Append( - promql.AndOperator, promql.NewTextWhere( - promql.MakeOrExpression(structured.ConvertToPromBuffer(condition)), - )) + influxdbCondition := structured.ConvertToPromBuffer(condition) + if len(influxdbCondition) > 0 { + whereList.Append( + promql.AndOperator, promql.NewTextWhere( + promql.MakeOrExpression(influxdbCondition), + )) + } + } // 增加时间维度查询,秒级转纳秒 if params.Start != "" && params.End != "" { diff --git a/pkg/unify-query/query/structured/query_ts.go b/pkg/unify-query/query/structured/query_ts.go index fca12cd5e..bb93ca5bf 100644 --- a/pkg/unify-query/query/structured/query_ts.go +++ b/pkg/unify-query/query/structured/query_ts.go @@ -353,12 +353,15 @@ func (q *Query) BuildMetadataQuery( measurements = []string{measurement} trace.InsertStringIntoSpan("tsdb-table-id", tsDB.TableID, span) + trace.InsertStringSliceIntoSpan("tsdb-field-list", tsDB.Field, span) + trace.InsertStringIntoSpan("tsdb-measurement-type", tsDB.MeasurementType, span) trace.InsertStringIntoSpan("tsdb-filters", fmt.Sprintf("%+v", tsDB.Filters), span) - trace.InsertStringIntoSpan("tsdb-db", db, span) + trace.InsertStringIntoSpan("tsdb-data-label", tsDB.DataLabel, span) trace.InsertStringIntoSpan("tsdb-storge-id", storageID, span) trace.InsertStringIntoSpan("tsdb-cluster-name", clusterName, span) trace.InsertStringIntoSpan("tsdb-tag-keys", fmt.Sprintf("%+v", tagKeys), span) trace.InsertStringIntoSpan("tsdb-vm-rt", vmRt, span) + trace.InsertStringIntoSpan("tsdb-db", db, span) trace.InsertStringIntoSpan("tsdb-measurements", fmt.Sprintf("%+v", measurements), span) if q.Offset != "" { @@ -373,14 +376,18 @@ func (q *Query) BuildMetadataQuery( query.LabelsMatcher = append(query.LabelsMatcher, queryLabelsMatcher...) // influxdb 查询特殊处理逻辑 - whereList.Append( - promql.AndOperator, - promql.NewTextWhere( - promql.MakeOrExpression( - ConvertToPromBuffer(queryConditions), + influxdbConditions := ConvertToPromBuffer(queryConditions) + if len(influxdbConditions) > 0 { + whereList.Append( + promql.AndOperator, + promql.NewTextWhere( + promql.MakeOrExpression( + influxdbConditions, + ), ), - ), - ) + ) + } + } switch tsDB.MeasurementType {