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

Method mergeWithOrSubQuery

query/sql/sql_parser.go:1565–1590  ·  view source on GitHub ↗

mergeWithOrSubQuery merge one subquery/withQuery information into v.aql

(key int, ignoreJoin bool)

Source from the content-addressed store, hash-verified

1563
1564// mergeWithOrSubQuery merge one subquery/withQuery information into v.aql
1565func (v *ASTBuilder) mergeWithOrSubQuery(key int, ignoreJoin bool) {
1566 if !ignoreJoin {
1567 v.aql.Table = v.SQL2AqlCtx.MapJoinTables[key][0].Table
1568 v.aql.Joins = v.SQL2AqlCtx.MapJoinTables[key][1:]
1569 }
1570
1571 for i, measure := range v.SQL2AqlCtx.MapMeasures[key] {
1572 if index := v.isMeasureInMain(key, i); index > -1 {
1573 // case1: this measure of subquery/withQuery is not a supportingMeasure
1574 v.SQL2AqlCtx.MapMeasures[0][index].Filters = v.SQL2AqlCtx.MapRowFilters[key]
1575 if len(v.SQL2AqlCtx.MapDimensions[0]) == 0 {
1576 v.SQL2AqlCtx.MapDimensions[0] = v.SQL2AqlCtx.MapDimensions[key]
1577 }
1578 } else {
1579 // case2: this measure of subquery/withQuery is a supportingMeasure
1580 measure.Filters = v.SQL2AqlCtx.MapRowFilters[key]
1581 v.aql.SupportingMeasures = append(v.aql.SupportingMeasures, measure)
1582 }
1583 if len(v.SQL2AqlCtx.MapDimensions[0]) == 0 && len(v.SQL2AqlCtx.MapDimensions[key]) != 0 {
1584 v.SQL2AqlCtx.MapDimensions[0] = v.SQL2AqlCtx.MapDimensions[key]
1585 }
1586 if len(v.aql.Sorts) == 0 && len(v.SQL2AqlCtx.MapOrderBy[key]) != 0 {
1587 v.aql.Sorts = v.SQL2AqlCtx.MapOrderBy[key]
1588 }
1589 }
1590}
1591
1592// isMeasureInMain check a measure of subquery/withQuery is also a measure of level 0 query
1593// return the index of the measure in level 0 query; otherwise return -1

Callers 1

mergeWithOrSubQueriesMethod · 0.95

Calls 1

isMeasureInMainMethod · 0.95

Tested by

no test coverage detected