MCPcopy
hub / github.com/uber/aresdb / isSameFromTables

Method isSameFromTables

query/sql/sql_parser.go:1802–1831  ·  view source on GitHub ↗

AQL requires that all subqueries or withQuery from clauses are same

(s2aCtx *SQL2AqlContext, mapKey int)

Source from the content-addressed store, hash-verified

1800
1801// AQL requires that all subqueries or withQuery from clauses are same
1802func (v *ASTBuilder) isSameFromTables(s2aCtx *SQL2AqlContext, mapKey int) (bool, error) {
1803 qLevel, _, index := v.getInfoByKey(mapKey)
1804 // generte from clause json bytes based on the first subquery/withQuery
1805 if s2aCtx.fromJSON == nil {
1806 withKeyMin := v.generateKey(qLevel, typeWithQuery, 0)
1807 subQKeyMin := v.generateKey(qLevel, typeSubQuery, 0)
1808 var err error
1809 if s2aCtx.MapJoinTables[withKeyMin] != nil {
1810 s2aCtx.fromJSON, err = json.Marshal(s2aCtx.MapJoinTables[withKeyMin])
1811 } else {
1812 s2aCtx.fromJSON, err = json.Marshal(s2aCtx.MapJoinTables[subQKeyMin])
1813 }
1814
1815 if err != nil {
1816 return false, errors.New("unable to encode from clause of the first subquery/withQuery")
1817 }
1818
1819 if index == 0 {
1820 return true, nil
1821 }
1822 }
1823
1824 // compare current from clause with ctx.fromJSON
1825 joins, err := json.Marshal(s2aCtx.MapJoinTables[mapKey])
1826 if err != nil {
1827 return false, errors.New("unable to encode from clause of this subquery/withQuery")
1828 }
1829
1830 return bytes.Equal(s2aCtx.fromJSON, joins), nil
1831}
1832
1833// AQL requires that all subqueries or withQuery groupBy clauses are sameo
1834func (v *ASTBuilder) isSameGroupBy(s2aCtx *SQL2AqlContext, mapKey int) (bool, error) {

Callers 1

isValidWithOrSubQueryMethod · 0.95

Calls 2

getInfoByKeyMethod · 0.95
generateKeyMethod · 0.95

Tested by

no test coverage detected