fix: add validations for aggregates on logs/traces datasource (#2709)

This commit is contained in:
Vishal Sharma 2023-05-18 17:16:06 +05:30 committed by GitHub
parent 81291c996f
commit d67f709b8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -374,6 +374,21 @@ var testBuildTracesQueryData = []struct {
" from signoz_traces.distributed_signoz_index_v2 where (timestamp >= '1680066360726210000' AND timestamp <= '1680066458000000000')" + " from signoz_traces.distributed_signoz_index_v2 where (timestamp >= '1680066360726210000' AND timestamp <= '1680066458000000000')" +
" group by ts order by ts", " group by ts order by ts",
}, },
{
Name: "Test aggregate rate without aggregate attribute",
Start: 1680066360726210000,
End: 1680066458000000000,
Step: 60,
BuilderQuery: &v3.BuilderQuery{
QueryName: "A",
AggregateOperator: v3.AggregateOperatorRate,
Expression: "A",
},
TableName: "signoz_traces.distributed_signoz_index_v2",
ExpectedQuery: "SELECT toStartOfInterval(timestamp, INTERVAL 60 SECOND) AS ts, count()/60 as value from" +
" signoz_traces.distributed_signoz_index_v2 where (timestamp >= '1680066360726210000' AND timestamp <=" +
" '1680066458000000000') group by ts order by ts",
},
{ {
Name: "Test aggregate count on fixed column of float64 type with filter", Name: "Test aggregate count on fixed column of float64 type with filter",
Start: 1680066360726210000, Start: 1680066360726210000,

View File

@ -104,10 +104,26 @@ func (a AggregateOperator) Validate() error {
func (a AggregateOperator) RequireAttribute(dataSource DataSource) bool { func (a AggregateOperator) RequireAttribute(dataSource DataSource) bool {
switch dataSource { switch dataSource {
case DataSourceMetrics: case DataSourceMetrics:
switch a {
case AggregateOperatorNoOp:
return false
default:
return true
}
case DataSourceLogs:
switch a { switch a {
case AggregateOperatorNoOp, case AggregateOperatorNoOp,
AggregateOperatorCount, AggregateOperatorCount,
AggregateOperatorCountDistinct: AggregateOperatorRate:
return false
default:
return true
}
case DataSourceTraces:
switch a {
case AggregateOperatorNoOp,
AggregateOperatorCount,
AggregateOperatorRate:
return false return false
default: default:
return true return true