MCPcopy
hub / github.com/grafana/tempo / validate

Method validate

pkg/traceql/ast_validate.go:272–299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

270}
271
272func (o UnaryOperation) validate() error {
273 if err := o.Expression.validate(); err != nil {
274 return err
275 }
276
277 // Disallow intrinsic=nil
278 if o.Op == OpNotExists {
279 if attr, ok := o.Expression.(Attribute); ok {
280 switch {
281 case attr.Intrinsic != IntrinsicNone:
282 return fmt.Errorf("%s=nil is not valid because intrinsics cannot be nil", attr.String())
283 case attr == NewScopedAttribute(AttributeScopeResource, false, "service.name"):
284 return fmt.Errorf("%s=nil is not valid because resource.service.name cannot be nil", attr.String())
285 }
286 }
287 }
288
289 t := o.Expression.impliedType()
290 if t == TypeAttribute {
291 return nil
292 }
293
294 if !o.Op.unaryTypesValid(t) {
295 return fmt.Errorf("illegal operation for the given type: %s", o.String())
296 }
297
298 return nil
299}
300
301func (s Static) validate() error {
302 return nil

Callers 1

newUnaryOperationFunction · 0.95

Calls 6

StringMethod · 0.95
NewScopedAttributeFunction · 0.85
unaryTypesValidMethod · 0.80
validateMethod · 0.65
impliedTypeMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected