Package org.teiid.query.sql.lang
Class Command
- java.lang.Object
-
- org.teiid.query.sql.lang.Command
-
- All Implemented Interfaces:
Cloneable
,LanguageObject
- Direct Known Subclasses:
Alter
,BatchedUpdateCommand
,Create
,CreateProcedureCommand
,Drop
,DynamicCommand
,ExplainCommand
,ProcedureContainer
,QueryCommand
,SourceTriggerActionPlanner.SourceEventCommand
,TriggerAction
public abstract class Command extends Object implements LanguageObject
A Command is an interface for all the language objects that are at the root of a language object tree representing a SQL statement. For instance, a Query command represents a SQL select query, an Update command represents a SQL update statement, etc.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.teiid.query.sql.LanguageObject
LanguageObject.Util
-
-
Field Summary
Fields Modifier and Type Field Description protected TempMetadataStore
tempGroupIDs
All temporary group IDs discovered while resolving this command.static int
TYPE_ALTER_PROC
static int
TYPE_ALTER_TRIGGER
static int
TYPE_ALTER_VIEW
static int
TYPE_BATCHED_UPDATE
Represents a batched sequence of UPDATE statementsstatic int
TYPE_CREATE
static int
TYPE_DELETE
Represents a SQL DELETE statementstatic int
TYPE_DROP
static int
TYPE_DYNAMIC
static int
TYPE_EXPLAIN
static int
TYPE_INSERT
Represents a SQL INSERT statementstatic int
TYPE_QUERY
Represents a SQL SELECT statementstatic int
TYPE_SOURCE_EVENT
static int
TYPE_STORED_PROCEDURE
Represents a stored procedure commandstatic int
TYPE_TRIGGER_ACTION
static int
TYPE_UNKNOWN
Represents an unknown type of commandstatic int
TYPE_UPDATE
Represents a SQL UPDATE statementstatic int
TYPE_UPDATE_PROCEDURE
Represents a update stored procedure command
-
Constructor Summary
Constructors Constructor Description Command()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addExternalGroupToContext(GroupSymbol group)
abstract boolean
areResultsCachable()
Whether the results are cachable.abstract Object
clone()
Implement clone to make objects cloneable.protected void
copyMetadataState(Command copy)
Command
getActualCommand()
For a statement such as explain, obtain the actual commandList<GroupSymbol>
getAllExternalGroups()
CacheHint
getCacheHint()
static String
getCommandToken(int commandType)
SymbolMap
getCorrelatedReferences()
Get the correlated references to the containing scope onlyGroupContext
getExternalGroupContexts()
Option
getOption()
Get the option clause for the query.ProcessorPlan
getProcessorPlan()
abstract List<Expression>
getProjectedSymbols()
Get the ordered list of all elements returned by this query.List<? extends Expression>
getResultSetColumns()
SourceHint
getSourceHint()
TempMetadataStore
getTemporaryMetadata()
abstract int
getType()
Return type of command to make it easier to build switch statements by command type.static List<Expression>
getUpdateCommandSymbol()
String
printCommandTree()
Print the full tree of commands with indentation - useful for debuggingprotected void
printCommandTree(StringBuffer str, int tabLevel)
Helper method to print command tree at given tab levelvoid
pushNewResolvingContext(Collection<GroupSymbol> groups)
boolean
returnsResultSet()
protected boolean
sameOptionAndHint(Command cmd)
void
setCacheHint(CacheHint cacheHint)
void
setCorrelatedReferences(SymbolMap correlatedReferences)
void
setExternalGroupContexts(GroupContext root)
void
setOption(Option option)
Set the option clause for the query.void
setProcessorPlan(ProcessorPlan plan)
void
setSourceHint(SourceHint sourceHint)
void
setTemporaryMetadata(TempMetadataStore metadata)
String
toString()
Returns a string representation of an instance of this class.-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.teiid.query.sql.LanguageObject
acceptVisitor
-
-
-
-
Field Detail
-
TYPE_UNKNOWN
public static final int TYPE_UNKNOWN
Represents an unknown type of command- See Also:
- Constant Field Values
-
TYPE_QUERY
public static final int TYPE_QUERY
Represents a SQL SELECT statement- See Also:
- Constant Field Values
-
TYPE_INSERT
public static final int TYPE_INSERT
Represents a SQL INSERT statement- See Also:
- Constant Field Values
-
TYPE_UPDATE
public static final int TYPE_UPDATE
Represents a SQL UPDATE statement- See Also:
- Constant Field Values
-
TYPE_DELETE
public static final int TYPE_DELETE
Represents a SQL DELETE statement- See Also:
- Constant Field Values
-
TYPE_STORED_PROCEDURE
public static final int TYPE_STORED_PROCEDURE
Represents a stored procedure command- See Also:
- Constant Field Values
-
TYPE_UPDATE_PROCEDURE
public static final int TYPE_UPDATE_PROCEDURE
Represents a update stored procedure command- See Also:
- Constant Field Values
-
TYPE_BATCHED_UPDATE
public static final int TYPE_BATCHED_UPDATE
Represents a batched sequence of UPDATE statements- See Also:
- Constant Field Values
-
TYPE_DYNAMIC
public static final int TYPE_DYNAMIC
- See Also:
- Constant Field Values
-
TYPE_CREATE
public static final int TYPE_CREATE
- See Also:
- Constant Field Values
-
TYPE_DROP
public static final int TYPE_DROP
- See Also:
- Constant Field Values
-
TYPE_TRIGGER_ACTION
public static final int TYPE_TRIGGER_ACTION
- See Also:
- Constant Field Values
-
TYPE_ALTER_VIEW
public static final int TYPE_ALTER_VIEW
- See Also:
- Constant Field Values
-
TYPE_ALTER_PROC
public static final int TYPE_ALTER_PROC
- See Also:
- Constant Field Values
-
TYPE_ALTER_TRIGGER
public static final int TYPE_ALTER_TRIGGER
- See Also:
- Constant Field Values
-
TYPE_EXPLAIN
public static final int TYPE_EXPLAIN
- See Also:
- Constant Field Values
-
TYPE_SOURCE_EVENT
public static final int TYPE_SOURCE_EVENT
- See Also:
- Constant Field Values
-
tempGroupIDs
protected TempMetadataStore tempGroupIDs
All temporary group IDs discovered while resolving this command. The key is a TempMetadataID and the value is an ordered List of TempMetadataID representing the elements.
-
-
Method Detail
-
getType
public abstract int getType()
Return type of command to make it easier to build switch statements by command type.- Returns:
- Type from TYPE constants
-
getCorrelatedReferences
public SymbolMap getCorrelatedReferences()
Get the correlated references to the containing scope only- Returns:
-
setCorrelatedReferences
public void setCorrelatedReferences(SymbolMap correlatedReferences)
-
setTemporaryMetadata
public void setTemporaryMetadata(TempMetadataStore metadata)
-
getTemporaryMetadata
public TempMetadataStore getTemporaryMetadata()
-
addExternalGroupToContext
public void addExternalGroupToContext(GroupSymbol group)
-
setExternalGroupContexts
public void setExternalGroupContexts(GroupContext root)
-
pushNewResolvingContext
public void pushNewResolvingContext(Collection<GroupSymbol> groups)
-
getExternalGroupContexts
public GroupContext getExternalGroupContexts()
-
getAllExternalGroups
public List<GroupSymbol> getAllExternalGroups()
-
clone
public abstract Object clone()
Description copied from interface:LanguageObject
Implement clone to make objects cloneable.- Specified by:
clone
in interfaceLanguageObject
- Overrides:
clone
in classObject
- Returns:
- Deep clone of this object
-
copyMetadataState
protected void copyMetadataState(Command copy)
-
printCommandTree
public String printCommandTree()
Print the full tree of commands with indentation - useful for debugging- Returns:
- String String representation of command tree
-
printCommandTree
protected void printCommandTree(StringBuffer str, int tabLevel)
Helper method to print command tree at given tab level- Parameters:
str
- String buffer to add command sub tree totabLevel
- Number of tabs to print this command at
-
getOption
public Option getOption()
Get the option clause for the query.- Returns:
- option clause
-
setOption
public void setOption(Option option)
Set the option clause for the query.- Parameters:
option
- New option clause
-
getProjectedSymbols
public abstract 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.- Returns:
- Ordered list of SingleElementSymbol
-
areResultsCachable
public abstract boolean areResultsCachable()
Whether the results are cachable.- Returns:
- True if the results are cachable; false otherwise.
-
getUpdateCommandSymbol
public static List<Expression> getUpdateCommandSymbol()
-
getProcessorPlan
public ProcessorPlan getProcessorPlan()
-
setProcessorPlan
public void setProcessorPlan(ProcessorPlan plan)
-
getCacheHint
public CacheHint getCacheHint()
-
setCacheHint
public void setCacheHint(CacheHint cacheHint)
-
getSourceHint
public SourceHint getSourceHint()
-
setSourceHint
public void setSourceHint(SourceHint sourceHint)
-
toString
public String toString()
Returns a string representation of an instance of this class.
-
sameOptionAndHint
protected boolean sameOptionAndHint(Command cmd)
-
returnsResultSet
public boolean returnsResultSet()
-
getResultSetColumns
public List<? extends Expression> getResultSetColumns()
- Returns:
- null if unknown, empty if results are not returned, or the resultset columns
-
getCommandToken
public static String getCommandToken(int commandType)
-
getActualCommand
public Command getActualCommand()
For a statement such as explain, obtain the actual command- Returns:
-
-