Skip to content

Commit

Permalink
feat(chsql): use simpleJSONHas to find attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Jun 24, 2024
1 parent 64e7127 commit 2428d85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions internal/chstorage/chsql/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func HasToken(haystack Expr, token string) Expr {
return Function("hasToken", haystack, String(token))
}

// SimpleJSONHas returns `simpleJSONHas(<json>, <field>)` function call expression.
func SimpleJSONHas(json Expr, field string) Expr {
return Function("simpleJSONHas", json, String(field))
}

// JSONExtract returns `JSONExtract(<from>, <typ>)` function call expression.
func JSONExtract(from Expr, typ string) Expr {
return Function("JSONExtract", from, String(typ))
Expand Down
6 changes: 3 additions & 3 deletions internal/chstorage/querier_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,9 @@ func getTraceQLMatcher(matcher traceql.SpanMatcher) (e chsql.Expr, _ bool) {
exprs = make([]chsql.Expr, 0, 3)
)
for _, column := range getTraceQLAttributeColumns(attr) {
exprs = append(exprs, chsql.Has(
attrKeys(column),
chsql.String(attr.Name),
exprs = append(exprs, chsql.SimpleJSONHas(
chsql.Ident(column),
attr.Name,
))
}
return chsql.JoinOr(exprs...), true
Expand Down

0 comments on commit 2428d85

Please sign in to comment.