Visitable
public class ColumnReference extends ValueNode
Modifier and Type | Class | Description |
---|---|---|
private static class |
ColumnReference.RemapInfo |
Helper class to keep track of remap data when a ColumnReference
is remapped multiple times.
|
Modifier and Type | Field | Description |
---|---|---|
private java.lang.String |
_columnName |
|
private int |
_mergeTableID |
Columns mentioned by MERGE statements need to be associated
the SOURCE or TARGET table
|
private int |
_origColumnNumber |
|
private ResultColumn |
_origSource |
|
private int |
_origTableNumber |
|
private TableName |
_qualifiedTableName |
|
private int |
columnNumber |
The column number in the underlying FromTable.
|
private int |
columnNumberBeforeFlattening |
|
static int |
MERGE_SOURCE |
|
static int |
MERGE_TARGET |
|
static int |
MERGE_UNKNOWN |
|
private int |
nestingLevel |
|
private java.lang.String |
origName |
|
private java.util.ArrayList<ColumnReference.RemapInfo> |
remaps |
|
private boolean |
replacesAggregate |
|
private boolean |
replacesWindowFunctionCall |
|
private boolean |
scoped |
|
private ResultColumn |
source |
This is where the value for this column reference will be coming from.
|
private int |
sourceLevel |
|
private int |
tableNumber |
The FromTable this column reference is bound to.
|
private int |
tableNumberBeforeFlattening |
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
transformed
Constructor | Description |
---|---|
ColumnReference(java.lang.String columnName,
TableName tableName,
int tokBeginOffset,
int tokEndOffset,
ContextManager cm) |
Constructor.
|
ColumnReference(java.lang.String columnName,
TableName tableName,
ContextManager cm) |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
(package private) void |
acceptChildren(Visitor v) |
Accept a visitor on all child nodes.
|
(package private) ColumnReference |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.List<AggregateNode> aggregates) |
Bind this expression.
|
(package private) boolean |
categorize(JBitSet referencedTabs,
boolean simplePredsOnly) |
Categorize this predicate.
|
(package private) boolean |
constantExpression(PredicateList whereClause) |
Return whether or not this expression tree represents a constant value.
|
(package private) void |
copyFields(ColumnReference oldCR) |
Copy all of the "appropriate fields" for a shallow copy.
|
(package private) void |
generateExpression(ExpressionClassBuilder acb,
MethodBuilder mb) |
ColumnReference's are to the current row in the system.
|
(package private) ValueNode |
getClone() |
Return a clone of this node.
|
java.lang.String |
getColumnName() |
Get the name of this column
|
(package private) int |
getColumnNumber() |
Get the column number for this ColumnReference.
|
(package private) boolean |
getCorrelated() |
Return whether or not this CR is correlated.
|
(package private) boolean |
getGeneratedToReplaceAggregate() |
Determine whether or not this node was generated to
replace an aggregate in the user's SELECT.
|
(package private) boolean |
getGeneratedToReplaceWindowFunctionCall() |
Determine whether or not this node was generated to
replace a window function call in the user's SELECT.
|
(package private) int |
getMergeTableID() |
Get the MERGE table (SOURCE or TARGET) associated with this column
|
private int |
getNestingLevel() |
Get the nesting level for this CR.
|
protected int |
getOrderableVariantType() |
Return the variant type for the underlying expression.
|
TableName |
getQualifiedTableName() |
Return the table name as the node it is.
|
(package private) java.lang.String |
getSchemaName() |
Get the user-supplied schema name of this column.
|
(package private) ResultColumn |
getSource() |
Get the source this columnReference
|
(package private) int |
getSourceLevel() |
Get the source level for this CR.
|
(package private) ResultColumn |
getSourceResultColumn() |
Get the source for this ValueNode.
|
protected ResultSetNode |
getSourceResultSet(int[] colNum) |
Find the source result set for this ColumnReference and
return it.
|
(package private) java.lang.String |
getSourceSchemaName() |
Get the name of the schema for the Column's base table, if any.
|
(package private) java.lang.String |
getSourceTableName() |
Get the name of the underlying(base) table this column comes from, if any.
|
(package private) java.lang.String |
getSQLColumnName() |
Get the column name for purposes of error
messages or debugging.
|
(package private) java.lang.String |
getTableName() |
Get the user-supplied table name of this column.
|
(package private) int |
getTableNumber() |
Get the table number for this ColumnReference.
|
(package private) void |
getTablesReferenced(JBitSet refs) |
Update the table map to reflect the source
of this CR.
|
(package private) DataTypeDescriptor |
getTypeServices() |
The type of a ColumnReference is the type of its
source unless the source is null then it is
the type that has been set on this node.
|
protected boolean |
hasBeenRemapped() |
Returns true if this ColumnReference has been remapped; false
otherwise.
|
(package private) boolean |
isCloneable() |
Return whether or not this expression tree is cloneable.
|
(package private) boolean |
isEquivalent(ValueNode o) |
Tests if this node is equivalent to the specified ValueNode.
|
protected boolean |
isScoped() |
Return whether or not this ColumnReference is scoped.
|
protected void |
markAsScoped() |
Mark this column reference as "scoped", which means that it
was created (as a clone of another ColumnReference) to serve
as the left or right operand of a scoped predicate.
|
(package private) void |
markGeneratedToReplaceAggregate() |
Mark this node as being generated to replace an aggregate.
|
(package private) void |
markGeneratedToReplaceWindowFunctionCall() |
Mark this node as being generated to replace a window function call.
|
(package private) boolean |
pointsToColumnReference() |
Return whether or not the source of this ColumnReference is itself a ColumnReference.
|
private java.lang.String |
prettyPrintMergeTableID(int mergeTableID) |
|
(package private) void |
printSubNodes(int depth) |
Prints the sub-nodes of this object.
|
(package private) ValueNode |
putAndsOnTop() |
Do the 1st step in putting an expression into conjunctive normal
form.
|
(package private) void |
remapColumnReferences() |
Remap all of the ColumnReferences in this expression tree
to point to the ResultColumn that is 1 level under their
current source ResultColumn.
|
(package private) ValueNode |
remapColumnReferencesToExpressions() |
Remap all ColumnReferences in this tree to be clones of the
underlying expression.
|
(package private) void |
setColumnNumber(int colNum) |
Set the column number for this ColumnReference.
|
(package private) void |
setMergeTableID(int mergeTableID) |
Associate this column with a SOURCE or TARGET table of a MERGE statement
|
(package private) void |
setNestingLevel(int nestingLevel) |
Set the nesting level for this CR.
|
(package private) void |
setQualifiedTableName(TableName tableName) |
|
(package private) void |
setSource(ResultColumn source) |
Set the source this columnReference
|
(package private) void |
setSourceLevel(int sourceLevel) |
Set the source level for this CR.
|
(package private) void |
setTableNumber(int tableNumber) |
Set this ColumnReference to refer to the given table number.
|
java.lang.String |
toString() |
Convert this object to a String.
|
(package private) void |
unRemapColumnReferences() |
|
boolean |
updatableByCursor() |
Is the column wirtable by the cursor or not.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
bindExpression, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, eliminateNots, evaluateConstantExpressions, genEqualsFalseTree, generate, genIsNullTree, genSQLJavaSQLTree, getConstantValueAsObject, getDataValueFactory, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isConstantExpression, isInListProbeNode, isParameterNode, isRelationalOperator, isSameNodeKind, optimizableEqualityNode, preprocess, requiresTypeFromContext, selectivity, setCollationInfo, setCollationInfo, setCollationUsingCompilationSchema, setCollationUsingCompilationSchema, setNullability, setTransformed, setType, setType, setType, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
public static final int MERGE_UNKNOWN
public static final int MERGE_SOURCE
public static final int MERGE_TARGET
private java.lang.String _columnName
private TableName _qualifiedTableName
private int tableNumber
private int columnNumber
source
.source
private ResultColumn source
tableNumber
/columnNumber
will
point to the column in the left or right join participant
FromTable
, whereas source
will be bound to the RC in the result
column list of the join node. See also the comment at the end of
JoinNode#getMatchingColumn.private ResultColumn _origSource
private java.lang.String origName
private int _origTableNumber
private int _origColumnNumber
private int tableNumberBeforeFlattening
private int columnNumberBeforeFlattening
private boolean replacesAggregate
private boolean replacesWindowFunctionCall
private int nestingLevel
private int sourceLevel
private boolean scoped
private java.util.ArrayList<ColumnReference.RemapInfo> remaps
private int _mergeTableID
ColumnReference(java.lang.String columnName, TableName tableName, int tokBeginOffset, int tokEndOffset, ContextManager cm)
columnName
- The name of the column being referencedtableName
- The qualification for the columntokBeginOffset
- begin position of token for the column name
identifier from parser.tokEndOffset
- end position of token for the column name
identifier from parser.cm
- The context managerColumnReference(java.lang.String columnName, TableName tableName, ContextManager cm)
columnName
- The name of the column being referencedtableName
- The qualification for the columncm
- The context managerpublic java.lang.String toString()
void printSubNodes(int depth)
printSubNodes
in class QueryTreeNode
depth
- The depth of this node in the treeboolean getCorrelated()
void setNestingLevel(int nestingLevel)
nestingLevel
- The Nesting level at which the CR appears.private int getNestingLevel()
void setSourceLevel(int sourceLevel)
sourceLevel
- The Nesting level of the source of the CR.int getSourceLevel()
void markGeneratedToReplaceAggregate()
void markGeneratedToReplaceWindowFunctionCall()
boolean getGeneratedToReplaceAggregate()
boolean getGeneratedToReplaceWindowFunctionCall()
ValueNode getClone() throws StandardException
getClone
in class ValueNode
StandardException
- Thrown on errorvoid copyFields(ColumnReference oldCR) throws StandardException
oldCR
- The ColumnReference to copy from.StandardException
- Thrown on errorColumnReference bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates) throws StandardException
bindExpression
in class ValueNode
fromList
- The FROM list for the query this
expression is in, for binding columns.subqueryList
- The subquery list being built as we find SubqueryNodesaggregates
- The aggregate list being built as we find AggregateNodesStandardException
- Thrown on errorjava.lang.String getSQLColumnName()
public java.lang.String getColumnName()
getColumnName
in class ValueNode
int getTableNumber()
void setTableNumber(int tableNumber)
tableNumber
- The table number this ColumnReference will refer tojava.lang.String getTableName()
getTableName
in class ValueNode
java.lang.String getSourceTableName()
java.lang.String getSourceSchemaName() throws StandardException
StandardException
public boolean updatableByCursor()
updatableByCursor
in class ValueNode
public TableName getQualifiedTableName()
void setQualifiedTableName(TableName tableName)
int getColumnNumber()
void setColumnNumber(int colNum)
colNum
- The new column number.ResultColumn getSource()
void setSource(ResultColumn source)
source
- The source of this columnReferenceValueNode putAndsOnTop() throws StandardException
putAndsOnTop
in class ValueNode
StandardException
- Thrown on errorboolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
categorize
in class ValueNode
referencedTabs
- JBitSet with bit map of referenced FromTablessimplePredsOnly
- Whether or not to consider method
calls, field references and conditional nodes
when building bit mapvoid remapColumnReferences()
void unRemapColumnReferences()
protected boolean hasBeenRemapped()
ResultColumn getSourceResultColumn()
ValueNode
getSourceResultColumn
in class ValueNode
ValueNode remapColumnReferencesToExpressions() throws StandardException
remapColumnReferencesToExpressions
in class ValueNode
StandardException
- Thrown on errorvoid getTablesReferenced(JBitSet refs)
refs
- The table map.boolean isCloneable()
isCloneable
in class ValueNode
boolean constantExpression(PredicateList whereClause)
ValueNode
constantExpression
in class ValueNode
ValueNode.constantExpression(org.apache.derby.impl.sql.compile.PredicateList)
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
generateExpression
in class ValueNode
acb
- The ExpressionClassBuilder for the class being builtmb
- The method the expression will go intoStandardException
- Thrown on errorjava.lang.String getSchemaName()
getSchemaName
in class ValueNode
protected int getOrderableVariantType()
getOrderableVariantType
in class ValueNode
boolean pointsToColumnReference()
DataTypeDescriptor getTypeServices()
getTypeServices
in class ValueNode
protected ResultSetNode getSourceResultSet(int[] colNum) throws StandardException
colNum
- Place to store the position of the column
to which this ColumnReference points (position is w.r.t
the source result set).StandardException
boolean isEquivalent(ValueNode o) throws StandardException
ValueNode
This method provides basic expression matching facility for the derived class of ValueNode and it is used by the language layer to compare the node structural form of the two expressions for equivalence at bind phase.
Note that it is not comparing the actual row values at runtime to produce a result; hence, when comparing SQL NULLs, they are considered to be equivalent and not unknown.
One usage case of this method in this context is to compare the select column expression against the group by expression to check if they are equivalent. e.g.:
SELECT c1+c2 FROM t1 GROUP BY c1+c2
In general, node equivalence is determined by the derived class of ValueNode. But they generally abide to the rules below:
isEquivalent
in class ValueNode
o
- the node to compare this ValueNode against.true
if the two nodes are equivalent,
false
otherwise.StandardException
protected void markAsScoped()
protected boolean isScoped()
void setMergeTableID(int mergeTableID)
private java.lang.String prettyPrintMergeTableID(int mergeTableID)
int getMergeTableID()
void acceptChildren(Visitor v) throws StandardException
QueryTreeNode
accept(v)
on all visitable fields, as well as
super.acceptChildren(v)
to make sure all visitable fields
defined by the super-class are accepted too.acceptChildren
in class QueryTreeNode
v
- the visitorStandardException
- on errors raised by the visitorApache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.