Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac committed Oct 11, 2024
1 parent 49b26b4 commit fd7af4e
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions connector/internal/native_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type NativeQueryExecutor struct {
// Explain explains the query request
func (nqe *NativeQueryExecutor) Explain(ctx context.Context) (*NativeQueryRequest, string, error) {
params, err := EvalNativeQueryRequest(nqe.Request, nqe.Arguments, nqe.Variables)
if err != nil {
return nil, "", err
}

queryString := nqe.NativeQuery.Query
for key, arg := range nqe.Arguments {
switch key {
Expand Down Expand Up @@ -246,10 +250,36 @@ func (nqe *NativeQueryExecutor) validateLabelBoolExp(labels model.Metric, expr s
return !slices.Contains(value, string(labelValue)), nil
}
}
// case *schema.ExpressionExists:
// case *schema.ExpressionNot:
// case *schema.ExpressionOr:
// case *schema.ExpressionUnaryComparisonOperator:
case *schema.ExpressionNot:
valid, err := nqe.validateLabelBoolExp(labels, exprs.Expression)
if err != nil {
return false, err
}
return !valid, nil
case *schema.ExpressionOr:
if len(exprs.Expressions) == 0 {
return true, nil
}
for _, e := range exprs.Expressions {
valid, err := nqe.validateLabelBoolExp(labels, e)
if err != nil {
return false, err
}
if valid {
return true, nil
}
}
return false, nil
case *schema.ExpressionUnaryComparisonOperator:
switch exprs.Operator {
case schema.UnaryComparisonOperatorIsNull:
_, ok := labels[model.LabelName(exprs.Column.Name)]
return !ok, nil
default:
return false, fmt.Errorf("unsupported comparison operator %s", exprs.Operator)
}
default:
return false, fmt.Errorf("unsupported expression %v", expr)
}
return false, nil
}

0 comments on commit fd7af4e

Please sign in to comment.