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

Method processFilters

query/aql_compiler.go:1419–1512  ·  view source on GitHub ↗

processFilters processes all filters and categorize them into common filters, prefilters, and time filters. It also collect column usages from the filters.

()

Source from the content-addressed store, hash-verified

1417// processFilters processes all filters and categorize them into common filters,
1418// prefilters, and time filters. It also collect column usages from the filters.
1419func (qc *AQLQueryContext) processFilters() {
1420 // OOPK engine only supports one measure per query.
1421 if len(qc.Query.Measures) != 1 {
1422 qc.Error = utils.StackError(nil, "expect one measure per query, but got %d",
1423 len(qc.Query.Measures))
1424 return
1425 }
1426
1427 // Categorize common filters and prefilters based on matched prefilters.
1428 commonFilters := qc.Query.Measures[0].FiltersParsed
1429 prefilters := qc.Prefilters
1430 for index, filter := range qc.Query.FiltersParsed {
1431 if len(prefilters) == 0 || prefilters[0] > index {
1432 // common filters
1433 commonFilters = append(commonFilters, filter)
1434 } else {
1435 qc.OOPK.Prefilters = append(qc.OOPK.Prefilters, filter)
1436 prefilters = prefilters[1:]
1437 }
1438 }
1439
1440 var geoFilterFound bool
1441 for _, filter := range commonFilters {
1442 foreignTableColumnDetector := foreignTableColumnDetector{}
1443 expr.Walk(&foreignTableColumnDetector, filter)
1444 if foreignTableColumnDetector.hasForeignTableColumn {
1445 var isGeoFilter bool
1446 if qc.OOPK.geoIntersection != nil {
1447 geoTableID := qc.OOPK.geoIntersection.shapeTableID
1448 joinSchema := qc.TableSchemaByName[qc.Query.Joins[geoTableID-1].Table]
1449 isGeoFilter = qc.matchGeoFilter(filter, geoTableID, joinSchema, geoFilterFound)
1450 if qc.Error != nil {
1451 return
1452 }
1453 }
1454
1455 if !isGeoFilter {
1456 qc.OOPK.ForeignTableCommonFilters = append(qc.OOPK.ForeignTableCommonFilters, filter)
1457 } else {
1458 geoFilterFound = true
1459 }
1460 } else {
1461 qc.OOPK.MainTableCommonFilters = append(qc.OOPK.MainTableCommonFilters, filter)
1462 }
1463 }
1464
1465 if qc.OOPK.geoIntersection != nil && !geoFilterFound {
1466 qc.Error = utils.StackError(nil, "Exact one geo filter is needed if geo intersection"+
1467 " is used during join")
1468 return
1469 }
1470
1471 // Process time filter.
1472 qc.processTimeFilter()
1473 if qc.Error != nil {
1474 return
1475 }
1476

Callers 2

CompileMethod · 0.95

Calls 4

matchGeoFilterMethod · 0.95
processTimeFilterMethod · 0.95
StackErrorFunction · 0.92
WalkFunction · 0.92

Tested by

no test coverage detected