com.akiban.sql.parser
Class ValueNode

java.lang.Object
  extended by com.akiban.sql.parser.QueryTreeNode
      extended by com.akiban.sql.parser.ValueNode
All Implemented Interfaces:
Visitable
Direct Known Subclasses:
BaseColumnNode, BinaryListOperatorNode, BinaryOperatorNode, CastNode, CoalesceFunctionNode, ColumnReference, ConditionalNode, ConstantNode, CurrentDatetimeOperatorNode, CurrentRowLocationNode, CurrentSequenceNode, DefaultNode, ExplicitCollateNode, GenerationClauseNode, InListOperatorNode, JavaToSQLValueNode, NextSequenceNode, ParameterNode, ResultColumn, RowConstructorNode, SimpleCaseNode, SpecialFunctionNode, SubqueryNode, TernaryOperatorNode, UnaryOperatorNode, VirtualColumnNode

public abstract class ValueNode
extends QueryTreeNode

A ValueNode is an abstract class for all nodes that can represent data values, that is, constants, columns, and expressions.


Field Summary
 
Fields inherited from class com.akiban.sql.parser.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
 
Constructor Summary
ValueNode()
           
 
Method Summary
 void copyFrom(QueryTreeNode node)
          Fill this node with a deep copy of the given node.
 String getColumnName()
          This is null so that the caller will substitute in the resultset generated name as needed.
 String getSchemaName()
          This returns the user-supplied schema name of the column.
 ResultColumn getSourceResultColumn()
          Get the source for this ValueNode.
 String getTableName()
          This returns the user-supplied table name of the column.
 DataTypeDescriptor getType()
          Get the DataTypeDescriptor from this ValueNode.
 TypeId getTypeId()
          Get the TypeId from this ValueNode.
 void init(Object typeId, Object precision, Object scale, Object isNullable, Object maximumWidth)
          Initializer for numeric types.
 boolean isBinaryEqualsOperatorNode()
          Returns true if this value node is a equals operator.
 boolean isBooleanFalse()
          Does this represent a false constant.
 boolean isBooleanTrue()
          Does this represent a true constant.
 boolean isConstantExpression()
          Return whether or not this expression tree represents a constant expression.
protected abstract  boolean isEquivalent(ValueNode other)
          Tests if this node is equivalent to the specified ValueNode.
 boolean isInListProbeNode()
          Returns true if this value node is an operator created for optimized performance of an IN list.
 boolean isParameterNode()
          Returns TRUE if this is a parameter node.
 boolean isRelationalOperator()
          Returns true if this ValueNode is a relational operator.
protected  boolean isSameNodeType(ValueNode other)
          Tests if this node is of the same type as the specified node as reported by QueryTreeNode.getNodeType().
 void setNullability(boolean nullability)
          Set the nullability of this value.
 void setType(DataTypeDescriptor type)
          Set the DataTypeDescriptor for this ValueNode.
 String toString()
          Convert this object to a String.
 
Methods inherited from class com.akiban.sql.parser.QueryTreeNode
accept, convertDefaultNode, debugFlush, debugPrint, formatNodeString, getBeginOffset, getDebugOutput, getEndOffset, getNodeFactory, getNodeType, getNullNode, getParserContext, getStatementType, getUserData, init, init, init, init, init, init, init, init, init, init, init, init, init, isInstanceOf, makeTableName, makeTableName, nodeHeader, printLabel, printSubNodes, setBeginOffset, setDebugOutput, setEndOffset, setNodeType, setParserContext, setUserData, stackPrint, treePrint, treePrint, treePrint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ValueNode

public ValueNode()
Method Detail

init

public void init(Object typeId,
                 Object precision,
                 Object scale,
                 Object isNullable,
                 Object maximumWidth)
          throws StandardException
Initializer for numeric types.

Overrides:
init in class QueryTreeNode
Parameters:
typeId - The TypeID of this new node
precision - The precision of this new node
scale - The scale of this new node
isNullable - The nullability of this new node
maximumWidth - The maximum width of this new node
Throws:
StandardException

copyFrom

public void copyFrom(QueryTreeNode node)
              throws StandardException
Fill this node with a deep copy of the given node.

Overrides:
copyFrom in class QueryTreeNode
Throws:
StandardException

toString

public String toString()
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Overrides:
toString in class QueryTreeNode
Returns:
This object as a String

getType

public DataTypeDescriptor getType()
Get the DataTypeDescriptor from this ValueNode.

Returns:
The DataTypeDescriptor from this ValueNode. This may be null if the node isn't bound yet.

setNullability

public void setNullability(boolean nullability)
                    throws StandardException
Set the nullability of this value.

Throws:
StandardException

getTypeId

public TypeId getTypeId()
                 throws StandardException
Get the TypeId from this ValueNode.

Returns:
The TypeId from this ValueNode. This may be null if the node isn't bound yet.
Throws:
StandardException

setType

public void setType(DataTypeDescriptor type)
             throws StandardException
Set the DataTypeDescriptor for this ValueNode. This method is overridden in ParameterNode.

Parameters:
type - The DataTypeDescriptor to set in this ValueNode
Throws:
StandardException

getSourceResultColumn

public ResultColumn getSourceResultColumn()
Get the source for this ValueNode.

Returns:
The source of this ValueNode, null if this node is not sourced by a column.

getSchemaName

public String getSchemaName()
                     throws StandardException
This returns the user-supplied schema name of the column. At this class level, it simply returns null. But, the subclasses of ValueNode will overwrite this method to return the user-supplied schema name. When the value node is in a result column of a select list, the user can request metadata information. The result column won't have a column descriptor, so we return some default information through the expression. This lets expressions that are simply columns return all of the info, and others use this supertype's default values.

Returns:
the default schema name for an expression -- null
Throws:
StandardException

getTableName

public String getTableName()
This returns the user-supplied table name of the column. At this class level, it simply returns null. But, the subclasses of ValueNode will overwrite this method to return the user-supplied table name. When the value node is in a result column of a select list, the user can request metadata information. The result column won't have a column descriptor, so we return some default information through the expression. This lets expressions that are simply columns return all of the info, and others use this supertype's default values.

Returns:
the default table name for an expression -- null

getColumnName

public String getColumnName()
This is null so that the caller will substitute in the resultset generated name as needed.

Returns:
the default column name for an expression -- null.

isConstantExpression

public boolean isConstantExpression()
Return whether or not this expression tree represents a constant expression.

Returns:
Whether or not this expression tree represents a constant expression.

isBooleanTrue

public boolean isBooleanTrue()
Does this represent a true constant.

Returns:
Whether or not this node represents a true constant.

isBooleanFalse

public boolean isBooleanFalse()
Does this represent a false constant.

Returns:
Whether or not this node represents a false constant.

isRelationalOperator

public boolean isRelationalOperator()
Returns true if this ValueNode is a relational operator. Relational Operators are <, <=, =, >, >=, <> as well as IS NULL and IS NOT NULL. This is the preferred way of figuring out if a ValueNode is relational or not.

See Also:
RelationalOperator, BinaryRelationalOperatorNode, IsNullNode

isBinaryEqualsOperatorNode

public boolean isBinaryEqualsOperatorNode()
Returns true if this value node is a equals operator.

See Also:
isRelationalOperator()

isInListProbeNode

public boolean isInListProbeNode()
Returns true if this value node is an operator created for optimized performance of an IN list. Or more specifically, returns true if this value node is an equals operator of the form "col = ?" that we generated during preprocessing to allow index multi-probing.


isParameterNode

public boolean isParameterNode()
Returns TRUE if this is a parameter node. We do lots of special things with Parameter Nodes.


isEquivalent

protected abstract boolean isEquivalent(ValueNode other)
                                 throws StandardException
Tests if this node is equivalent to the specified ValueNode. Two ValueNodes are considered equivalent if they will evaluate to the same value during query execution.

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:

Parameters:
other - the node to compare this ValueNode against.
Returns:
true if the two nodes are equivalent, false otherwise.
Throws:
StandardException

isSameNodeType

protected final boolean isSameNodeType(ValueNode other)
Tests if this node is of the same type as the specified node as reported by QueryTreeNode.getNodeType().

Parameters:
other - the node to compare this value node against.
Returns:
true if the two nodes are of the same type.


Copyright © 2013 Akiban Technologies, Inc. All rights reserved.