Package org.teiid.query.sql.lang
Class Query
- java.lang.Object
-
- org.teiid.query.sql.lang.Command
-
- org.teiid.query.sql.lang.QueryCommand
-
- org.teiid.query.sql.lang.Query
-
- All Implemented Interfaces:
Cloneable
,FilteredCommand
,LanguageObject
public class Query extends QueryCommand implements FilteredCommand
A representation of a data query. A query consists of various parts, referred to as clauses. The following list the types of clauses that a query can hold, and their purpose:CLAUSE PURPOSE ========= ============================================== Select Defines the variables data to be retrieved for From Defines the groups to retrieve data from Criteria Defines constraints on data retrieval ("where") GroupBy Defines how rows being returned should be grouped Having Defines how groups should be filtered, also a criteria OrderBy Defines how the results should be sorted Option Defines any extra options on the query
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.teiid.query.sql.LanguageObject
LanguageObject.Util
-
-
Field Summary
-
Fields inherited from class org.teiid.query.sql.lang.Command
tempGroupIDs, TYPE_ALTER_PROC, TYPE_ALTER_TRIGGER, TYPE_ALTER_VIEW, TYPE_BATCHED_UPDATE, TYPE_CREATE, TYPE_DELETE, TYPE_DROP, TYPE_DYNAMIC, TYPE_EXPLAIN, TYPE_INSERT, TYPE_QUERY, TYPE_SOURCE_EVENT, TYPE_STORED_PROCEDURE, TYPE_TRIGGER_ACTION, TYPE_UNKNOWN, TYPE_UPDATE, TYPE_UPDATE_PROCEDURE
-
-
Constructor Summary
Constructors Constructor Description Query()
Constructs a default instance of this class.Query(Select select, From from, Criteria criteria, GroupBy groupBy, Criteria having, OrderBy orderBy, Option option)
Constructs an instance of this class given all the clausesQuery(Select select, From from, Criteria criteria, OrderBy orderBy, Option option)
Constructs an instance of this class given the specified clauses
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor.static boolean
areColumnsCachable(Collection<? extends Expression> projectedSymbols)
boolean
areResultsCachable()
Whether the results are cachable.void
clearCriteria()
Set the criteria clause to nullObject
clone()
Deep clone Query to produce a new identical query.boolean
equals(Object obj)
Compare two queries for equality.Criteria
getCriteria()
Get the criteria clause for the query.From
getFrom()
Get the from clause for the query.GroupBy
getGroupBy()
Get the group by clause for the query.Criteria
getHaving()
Get the having clause for the query.Into
getInto()
Query
getProjectedQuery()
List<Expression>
getProjectedSymbols()
Get the ordered list of all elements returned by this query.Select
getSelect()
Get the select clause for the query.int
getType()
Return type of command.boolean
hasAggregates()
int
hashCode()
Get hashcode for query.boolean
isRowConstructor()
boolean
returnsResultSet()
static Query
rowConstructor(List<Expression> select)
void
setCriteria(Criteria criteria)
Set the criteria clause for the query.void
setFrom(From from)
Set the from clause for the query.void
setGroupBy(GroupBy groupBy)
Set the group by clause for the query.void
setHaving(Criteria having)
Set the criteria clause for the query.void
setInto(Into into)
void
setRowConstructor(boolean isRowConstructor)
void
setSelect(Select select)
Set the select clause for the query.-
Methods inherited from class org.teiid.query.sql.lang.QueryCommand
getLimit, getOrderBy, getWith, setLimit, setOrderBy, setWith
-
Methods inherited from class org.teiid.query.sql.lang.Command
addExternalGroupToContext, copyMetadataState, getActualCommand, getAllExternalGroups, getCacheHint, getCommandToken, getCorrelatedReferences, getExternalGroupContexts, getOption, getProcessorPlan, getResultSetColumns, getSourceHint, getTemporaryMetadata, getUpdateCommandSymbol, printCommandTree, printCommandTree, pushNewResolvingContext, sameOptionAndHint, setCacheHint, setCorrelatedReferences, setExternalGroupContexts, setOption, setProcessorPlan, setSourceHint, setTemporaryMetadata, toString
-
-
-
-
Constructor Detail
-
Query
public Query()
Constructs a default instance of this class.
-
Query
public Query(Select select, From from, Criteria criteria, OrderBy orderBy, Option option)
Constructs an instance of this class given the specified clauses- Parameters:
select
- SELECT clausefrom
- FROM clausecriteria
- WHERE clauseorderBy
- ORDER BY clauseoption
- OPTION clause
-
Query
public Query(Select select, From from, Criteria criteria, GroupBy groupBy, Criteria having, OrderBy orderBy, Option option)
Constructs an instance of this class given all the clauses- Parameters:
select
- SELECT clausefrom
- FROM clausecriteria
- WHERE clausegroupBy
- GROUP BY clausehaving
- HAVING clauseorderBy
- ORDER BY clauseoption
- OPTION clause
-
-
Method Detail
-
rowConstructor
public static Query rowConstructor(List<Expression> select)
-
getType
public int getType()
Return type of command.
-
getSelect
public Select getSelect()
Get the select clause for the query.- Returns:
- SELECT clause
-
setSelect
public void setSelect(Select select)
Set the select clause for the query.- Parameters:
select
- SELECT clause
-
getFrom
public From getFrom()
Get the from clause for the query.- Returns:
- FROM clause
-
setFrom
public void setFrom(From from)
Set the from clause for the query.- Parameters:
from
- FROM clause
-
getCriteria
public Criteria getCriteria()
Get the criteria clause for the query.- Specified by:
getCriteria
in interfaceFilteredCommand
- Returns:
- WHERE clause
-
setCriteria
public void setCriteria(Criteria criteria)
Set the criteria clause for the query.- Specified by:
setCriteria
in interfaceFilteredCommand
- Parameters:
criteria
- WHERE clause
-
clearCriteria
public void clearCriteria()
Set the criteria clause to null
-
getGroupBy
public GroupBy getGroupBy()
Get the group by clause for the query.- Returns:
- GROUP BY clause
-
setGroupBy
public void setGroupBy(GroupBy groupBy)
Set the group by clause for the query.- Parameters:
groupBy
- GROUP BY clause
-
getHaving
public Criteria getHaving()
Get the having clause for the query.- Returns:
- HAVING clause
-
setHaving
public void setHaving(Criteria having)
Set the criteria clause for the query.- Parameters:
having
- HAVING clause
-
getInto
public Into getInto()
- Returns:
-
setInto
public void setInto(Into into)
- Parameters:
into
-
-
acceptVisitor
public void acceptVisitor(LanguageVisitor visitor)
Description copied from interface:LanguageObject
Method for accepting a visitor. It is the responsibility of the language object to call back on the visitor.- Specified by:
acceptVisitor
in interfaceLanguageObject
- Parameters:
visitor
- Visitor being used
-
getProjectedSymbols
public List<Expression> getProjectedSymbols()
Get the ordered list of all elements returned by this query. These elements may be ElementSymbols or ExpressionSymbols but in all cases each represents a single column.- Specified by:
getProjectedSymbols
in classCommand
- Returns:
- Ordered list of SingleElementSymbol
-
clone
public Object clone()
Deep clone Query to produce a new identical query.- Specified by:
clone
in interfaceLanguageObject
- Specified by:
clone
in classCommand
- Returns:
- Deep clone
-
equals
public boolean equals(Object obj)
Compare two queries for equality. Queries will only evaluate to equal if they are IDENTICAL: select variables are in the same order, criteria are in the same exact structure.
-
hashCode
public int hashCode()
Get hashcode for query. WARNING: This hash code relies on the hash codes of the Select and Criteria clauses. If the query changes, it's hash code will change and it can be lost from collections. Hash code is only valid after query has been completely constructed.
-
areResultsCachable
public boolean areResultsCachable()
Description copied from class:Command
Whether the results are cachable.- Specified by:
areResultsCachable
in classCommand
- Returns:
- True if the results are cachable; false otherwise.
- See Also:
Command.areResultsCachable()
-
areColumnsCachable
public static boolean areColumnsCachable(Collection<? extends Expression> projectedSymbols)
-
getProjectedQuery
public Query getProjectedQuery()
- Specified by:
getProjectedQuery
in classQueryCommand
- See Also:
QueryCommand.getProjectedQuery()
-
returnsResultSet
public boolean returnsResultSet()
- Overrides:
returnsResultSet
in classQueryCommand
-
hasAggregates
public boolean hasAggregates()
-
isRowConstructor
public boolean isRowConstructor()
-
setRowConstructor
public void setRowConstructor(boolean isRowConstructor)
-
-