Skip to content

Commit

Permalink
fix predicate adding
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Elliott <[email protected]>
  • Loading branch information
joe-elliott committed Mar 21, 2024
1 parent f315f1f commit 48b159b
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions tempodb/encoding/vparquet3/block_traceql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1135,12 +1135,25 @@ func createSpanIterator(makeIter makeIterFn, primaryIter parquetquery.Iterator,
nestedSetParentExplicit = false
)

// todo: improve these methods. if addPredicate gets a nil predicate shouldn't it just wipe out the existing predicates instead of appending?
// nil predicate matches everything. what's the point of also evaluating a "real" predicate?
addPredicate := func(columnPath string, p parquetquery.Predicate) {
columnPredicates[columnPath] = append(columnPredicates[columnPath], p)
}

selectColumnIfNotAlready := func(path string) {
if columnPredicates[path] == nil {
addNilPredicateIfNotAlready := func(path string) {
preds := columnPredicates[path]
foundOpNone := false

// check to see if there is a nil predicate and only add if it doesn't exist
for _, pred := range preds {
if pred == nil {
foundOpNone = true
break
}
}

if !foundOpNone {
addPredicate(path, nil)
columnSelectAs[path] = path
}
Expand Down Expand Up @@ -1212,17 +1225,17 @@ func createSpanIterator(makeIter makeIterFn, primaryIter parquetquery.Iterator,
continue

case traceql.IntrinsicStructuralDescendant:
selectColumnIfNotAlready(columnPathSpanNestedSetLeft)
selectColumnIfNotAlready(columnPathSpanNestedSetRight)
addNilPredicateIfNotAlready(columnPathSpanNestedSetLeft)
addNilPredicateIfNotAlready(columnPathSpanNestedSetRight)
continue

case traceql.IntrinsicStructuralChild:
selectColumnIfNotAlready(columnPathSpanNestedSetLeft)
selectColumnIfNotAlready(columnPathSpanParentID)
addNilPredicateIfNotAlready(columnPathSpanNestedSetLeft)
addNilPredicateIfNotAlready(columnPathSpanParentID)
continue

case traceql.IntrinsicStructuralSibling:
selectColumnIfNotAlready(columnPathSpanParentID)
addNilPredicateIfNotAlready(columnPathSpanParentID)
continue

case traceql.IntrinsicNestedSetLeft:
Expand Down

0 comments on commit 48b159b

Please sign in to comment.