mirror of
https://github.com/SigNoz/signoz.git
synced 2026-08-08 06:00:42 +01:00
Some checks failed
build-staging / prepare (push) Has been cancelled
build-staging / js-build (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
cacheci / tests (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
* feat: support llm trace list and span list * fix: take perf into consideration * fix: more tests * fix: more cleanup * fix: cleanup and more tests * fix: add resource fingerprint cte * fix: edge cases and correct cost key * fix: update integration test * fix: update openapi * fix: address comments * fix: address comments * fix: fix tests * fix: add back the flag in metadata * fix: remove source and change to builder ai query * fix: updated openapi * fix: minor cleanup * fix: refactor as requested * fix: address comments * fix: address comments * fix: remove tracefield. explicit rejection * fix: remove comment * fix: remove accidentally added file * fix: add NewFactory * fix: refactor integration tests * fix: address comment * fix: use assert * fix: use assert and condense comments
48 lines
1.9 KiB
Go
48 lines
1.9 KiB
Go
package scopedtracesstatementbuilder
|
|
|
|
import (
|
|
"context"
|
|
|
|
qbtypes "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5"
|
|
"github.com/SigNoz/signoz/pkg/types/telemetrytypes"
|
|
"github.com/SigNoz/signoz/pkg/valuer"
|
|
"github.com/huandu/go-sqlbuilder"
|
|
)
|
|
|
|
// predicateResolver resolves key + operator + value to boolean predicates through the
|
|
// shared condition builder. Args bind into sb as $n markers, so returned predicates
|
|
// can be embedded anywhere in sb; maskExpr is set by the builder after resolveMask
|
|
// (Scoped* aggregates embed it).
|
|
type predicateResolver struct {
|
|
cb qbtypes.ConditionBuilder
|
|
keys map[string][]*telemetrytypes.TelemetryFieldKey
|
|
sb *sqlbuilder.SelectBuilder
|
|
maskExpr string
|
|
}
|
|
|
|
func newPredicateResolver(cb qbtypes.ConditionBuilder, keys map[string][]*telemetrytypes.TelemetryFieldKey, sb *sqlbuilder.SelectBuilder) *predicateResolver {
|
|
return &predicateResolver{cb: cb, keys: keys, sb: sb}
|
|
}
|
|
|
|
// ConditionFor returns a boolean predicate for key via the condition builder
|
|
// (materialized column when present, else map access), args bound into sb.
|
|
func (r *predicateResolver) ConditionFor(ctx context.Context, orgID valuer.UUID, startNs, endNs uint64, key *telemetrytypes.TelemetryFieldKey, op qbtypes.FilterOperator, value any) (string, error) {
|
|
conds, _, err := r.cb.ConditionFor(ctx, orgID, startNs, endNs, key, r.keys, qbtypes.ConditionBuilderOptions{}, op, value, r.sb)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
if len(conds) == 0 {
|
|
return "", nil
|
|
}
|
|
// one condition per data-type variant of the key; OR them all
|
|
if len(conds) == 1 {
|
|
return conds[0], nil
|
|
}
|
|
return r.sb.Or(conds...), nil
|
|
}
|
|
|
|
// ExistsFor returns the EXISTS predicate for key.
|
|
func (r *predicateResolver) ExistsFor(ctx context.Context, orgID valuer.UUID, startNs, endNs uint64, key *telemetrytypes.TelemetryFieldKey) (string, error) {
|
|
return r.ConditionFor(ctx, orgID, startNs, endNs, key, qbtypes.FilterOperatorExists, nil)
|
|
}
|