github.com/rohankumardubey/aresdb@v0.0.2-0.20190517170215-e54e3ca06b9c/query/sql/tree/Query.go (about) 1 // Copyright (c) 2017-2018 Uber Technologies, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package tree 16 17 import "fmt" 18 19 // Query is query 20 type Query struct { 21 // Statement is IStatement 22 IStatement 23 // QueryBody is IQueryBody 24 QueryBody IQueryBody 25 // With is with 26 With *With 27 // OrderBy is orderby 28 OrderBy *OrderBy 29 // Limit is limit 30 Limit string 31 } 32 33 // NewQuery creates Query 34 func NewQuery(location *NodeLocation, with *With, queryBody IQueryBody, order *OrderBy, limit string) *Query { 35 if queryBody == nil { 36 panic(fmt.Errorf("QueryBody is null at (line:%d, col:%d)", location.Line, location.CharPosition)) 37 } 38 39 return &Query{ 40 IStatement: NewStatement(location), 41 QueryBody: queryBody, 42 With: with, 43 OrderBy: order, 44 Limit: limit, 45 } 46 } 47 48 // Accept accepts visitor 49 func (n *Query) Accept(visitor AstVisitor, ctx interface{}) interface{} { 50 return visitor.VisitQuery(n, ctx) 51 }