AQL requires that all subqueries or withQuery groupBy clauses are sameo
(s2aCtx *SQL2AqlContext, mapKey int)
| 1832 | |
| 1833 | // AQL requires that all subqueries or withQuery groupBy clauses are sameo |
| 1834 | func (v *ASTBuilder) isSameGroupBy(s2aCtx *SQL2AqlContext, mapKey int) (bool, error) { |
| 1835 | qLevel, _, index := v.getInfoByKey(mapKey) |
| 1836 | // generte group by clause json bytes based on the first subquery/withQuery |
| 1837 | if s2aCtx.groupByJSON == nil { |
| 1838 | withKeyMin := v.generateKey(qLevel, typeWithQuery, 0) |
| 1839 | subQKeyMin := v.generateKey(qLevel, typeSubQuery, 0) |
| 1840 | var err error |
| 1841 | if s2aCtx.MapJoinTables[withKeyMin] != nil { |
| 1842 | s2aCtx.groupByJSON, err = json.Marshal(s2aCtx.MapDimensions[withKeyMin]) |
| 1843 | } else { |
| 1844 | s2aCtx.groupByJSON, err = json.Marshal(s2aCtx.MapDimensions[subQKeyMin]) |
| 1845 | } |
| 1846 | if err != nil { |
| 1847 | return false, errors.New("unable to encode group by clause of the first subquery/withQuery") |
| 1848 | } |
| 1849 | |
| 1850 | if index == 0 { |
| 1851 | return true, nil |
| 1852 | } |
| 1853 | } |
| 1854 | |
| 1855 | // compare current groupBy clause with ctx.groupByJSON |
| 1856 | groupBy, err := json.Marshal(s2aCtx.MapDimensions[mapKey]) |
| 1857 | if err != nil { |
| 1858 | return false, errors.New("unable to encode group by clause of this subquery/withQuery") |
| 1859 | } |
| 1860 | |
| 1861 | return bytes.EqualFold(s2aCtx.groupByJSON, groupBy), nil |
| 1862 | } |
| 1863 | |
| 1864 | // AQL requires that all subqueries or withQuery orderBy clauses are same |
| 1865 | func (v *ASTBuilder) isSameOrderBy(s2aCtx *SQL2AqlContext, mapKey int) (bool, error) { |
no test coverage detected