feat: handle static fields correcty in aggreagte attribute keys (#2598)

This commit is contained in:
Nityananda Gohain 2023-04-20 13:09:32 +05:30 committed by GitHub
parent 2e4f0cfc33
commit 9557cb2f70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3803,6 +3803,7 @@ func (r *ClickHouseReader) GetLogAggregateAttributes(ctx context.Context, req *v
var err error
var rows driver.Rows
var response v3.AggregateAttributeResponse
var stringAllowed bool
where := ""
switch req.Operator {
@ -3810,6 +3811,7 @@ func (r *ClickHouseReader) GetLogAggregateAttributes(ctx context.Context, req *v
v3.AggregateOperatorCountDistinct,
v3.AggregateOpeatorCount:
where = "tagKey ILIKE $1"
stringAllowed = true
case
v3.AggregateOperatorRateSum,
v3.AggregateOperatorRateMax,
@ -3830,6 +3832,7 @@ func (r *ClickHouseReader) GetLogAggregateAttributes(ctx context.Context, req *v
v3.AggregateOperatorMin,
v3.AggregateOperatorMax:
where = "tagKey ILIKE $1 AND (tagDataType='int64' or tagDataType='float64')"
stringAllowed = false
case
v3.AggregateOperatorNoOp:
return &v3.AggregateAttributeResponse{}, nil
@ -3868,10 +3871,12 @@ func (r *ClickHouseReader) GetLogAggregateAttributes(ctx context.Context, req *v
response.AttributeKeys = append(response.AttributeKeys, key)
}
// add other attributes
for _, f := range constants.StaticFieldsLogsV3 {
if len(req.SearchText) == 0 || strings.Contains(f.Key, req.SearchText) {
f.IsColumn = isColumn(statements[0].Statement, f.Key)
response.AttributeKeys = append(response.AttributeKeys, f)
for _, field := range constants.StaticFieldsLogsV3 {
if !stringAllowed && field.DataType == v3.AttributeKeyDataTypeString {
continue
} else if len(req.SearchText) == 0 || strings.Contains(field.Key, req.SearchText) {
field.IsColumn = isColumn(statements[0].Statement, field.Key)
response.AttributeKeys = append(response.AttributeKeys, field)
}
}