Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions pkg/types/querybuildertypes/querybuildertypesv5/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ func (q *QueryBuilderQuery[T]) Validate(requestType RequestType) error {
return err
}

// Validate GroupBy
if err := q.validateGroupByFields(); err != nil {
return err
}

if requestType != RequestTypeRaw && requestType != RequestTypeTrace && len(q.Aggregations) > 0 {
if err := q.validateOrderByForAggregation(); err != nil {
return err
Expand Down Expand Up @@ -168,6 +173,27 @@ func (q *QueryBuilderQuery[T]) validateSelectFields() error {
"isRoot and isEntryPoint fields are not supported in selectFields",
)
}

// for logs the selectFields is not present.
// in traces, timestamp is added by default, so it will conflict with timestamp attribute.
if v.Name == "timestamp" {
return errors.NewInvalidInputf(
errors.CodeInvalidInput,
"timestamp field is not supported in selectFields, it's added by default where needed",
)
}
}
return nil
}

func (q *QueryBuilderQuery[T]) validateGroupByFields() error {
for _, v := range q.GroupBy {
if v.Name == "timestamp" {
return errors.NewInvalidInputf(
errors.CodeInvalidInput,
"timestamp field is not supported in groupBy, it's added by default where needed",
)
}
}
return nil
}
Expand Down
Loading