(conditions []traceql.Condition)
| 908 | } |
| 909 | |
| 910 | func checkConditions(conditions []traceql.Condition) error { |
| 911 | for _, cond := range conditions { |
| 912 | opCount := len(cond.Operands) |
| 913 | |
| 914 | switch cond.Op { |
| 915 | |
| 916 | case traceql.OpNone, traceql.OpExists: |
| 917 | if opCount != 0 { |
| 918 | return fmt.Errorf("operation %v must have 0 arguments. condition: %+v", cond.Op, cond) |
| 919 | } |
| 920 | |
| 921 | case traceql.OpEqual, traceql.OpNotEqual, |
| 922 | traceql.OpGreater, traceql.OpGreaterEqual, |
| 923 | traceql.OpLess, traceql.OpLessEqual, |
| 924 | traceql.OpRegex, traceql.OpNotRegex, |
| 925 | traceql.OpIn, traceql.OpNotIn, |
| 926 | traceql.OpRegexMatchAny, traceql.OpRegexMatchNone: |
| 927 | if opCount != 1 { |
| 928 | return fmt.Errorf("operation %v must have exactly 1 argument. condition: %+v", cond.Op, cond) |
| 929 | } |
| 930 | |
| 931 | case traceql.OpNotExists: |
| 932 | if opCount != 0 { |
| 933 | return fmt.Errorf("operation %v must have 0 arguments. condition: %+v", cond.Op, cond) |
| 934 | } |
| 935 | if cond.Attribute.Intrinsic != traceql.IntrinsicNone { |
| 936 | return fmt.Errorf("intrinsics cannot be = nil") |
| 937 | } |
| 938 | if cond.Attribute == traceql.NewScopedAttribute(traceql.AttributeScopeResource, false, "service.name") { |
| 939 | return fmt.Errorf("resource.service.name cannot be = nil") |
| 940 | } |
| 941 | |
| 942 | default: |
| 943 | return fmt.Errorf("unknown operation. condition: %+v", cond) |
| 944 | } |
| 945 | |
| 946 | // Check for conditions that are not supported in vParquet3 |
| 947 | if cond.Attribute.Intrinsic == traceql.IntrinsicEventName || |
| 948 | cond.Attribute.Intrinsic == traceql.IntrinsicLinkTraceID || |
| 949 | cond.Attribute.Intrinsic == traceql.IntrinsicLinkSpanID || |
| 950 | cond.Attribute.Intrinsic == traceql.IntrinsicInstrumentationName || |
| 951 | cond.Attribute.Intrinsic == traceql.IntrinsicInstrumentationVersion || |
| 952 | cond.Attribute.Intrinsic == traceql.IntrinsicChildCount { |
| 953 | |
| 954 | return fmt.Errorf("intrinsic '%s' not supported in vParquet3: %w", cond.Attribute.Intrinsic, util.ErrUnsupported) |
| 955 | } |
| 956 | if cond.Attribute.Scope == traceql.AttributeScopeEvent || cond.Attribute.Scope == traceql.AttributeScopeLink || cond.Attribute.Scope == traceql.AttributeScopeInstrumentation { |
| 957 | return fmt.Errorf("scope '%s' not supported in vParquet3: %w", cond.Attribute.Scope, util.ErrUnsupported) |
| 958 | } |
| 959 | |
| 960 | // Verify all operands are of the same type |
| 961 | if opCount == 0 { |
| 962 | continue |
| 963 | } |
| 964 | |
| 965 | for i := 1; i < opCount; i++ { |
| 966 | if reflect.TypeOf(cond.Operands[0]) != reflect.TypeOf(cond.Operands[i]) { |
| 967 | return fmt.Errorf("operands must be of the same type. condition: %+v", cond) |
no test coverage detected