MCPcopy Index your code
hub / github.com/uber/aresdb / rewriteIsOp

Function rewriteIsOp

query/expr/parser.go:241–270  ·  view source on GitHub ↗
(expr Expr)

Source from the content-addressed store, hash-verified

239}
240
241func rewriteIsOp(expr Expr) (Token, error) {
242 affirmative := true
243 if unary, ok := expr.(*UnaryExpr); ok {
244 if unary.Op == NOT {
245 affirmative = false
246 expr = unary.Expr
247 } else {
248 return IS, fmt.Errorf("bad literal %s following IS", expr.String())
249 }
250 }
251 switch e := expr.(type) {
252 case *NullLiteral:
253 if affirmative {
254 return IS_NULL, nil
255 }
256 return IS_NOT_NULL, nil
257 case *UnknownLiteral:
258 if affirmative {
259 return IS_NULL, nil
260 }
261 return IS_NOT_NULL, nil
262 case *BooleanLiteral:
263 if affirmative == e.Val {
264 return IS_TRUE, nil
265 }
266
267 return IS_FALSE, nil
268 }
269 return IS, fmt.Errorf("bad literal %s following IS (NOT)", expr.String())
270}
271
272func rewriteIsExpr(expr Expr) (Expr, error) {
273 e, ok := expr.(*BinaryExpr)

Callers 1

rewriteIsExprFunction · 0.85

Calls 2

ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected