Class UnaryDateTimestampOperatorNode

  • All Implemented Interfaces:
    Visitable

    class UnaryDateTimestampOperatorNode
    extends UnaryOperatorNode
    This class implements the timestamp( x) and date(x) functions. These two functions implement a few special cases of string conversions beyond the normal string to date/timestamp casts.
    • Constructor Detail

      • UnaryDateTimestampOperatorNode

        UnaryDateTimestampOperatorNode​(ValueNode operand,
                                       int kind,
                                       ContextManager cm)
                                throws StandardException
        Parameters:
        operand - The operand of the function
        kind - The kind of the result, Date or Timestamp.
        cm - context manager
        Throws:
        StandardException
    • Method Detail

      • bindExpression

        ValueNode bindExpression​(FromList fromList,
                                 SubqueryList subqueryList,
                                 java.util.List<AggregateNode> aggregates)
                          throws StandardException
        Called by UnaryOperatorNode.bindExpression. If the operand is a constant then evaluate the function at compile time. Otherwise, if the operand input type is the same as the output type then discard this node altogether. If the function is "date" and the input is a timestamp then change this node to a cast.
        Overrides:
        bindExpression in class UnaryOperatorNode
        Parameters:
        fromList - The FROM list for the query this expression is in, for binding columns.
        subqueryList - The subquery list being built as we find SubqueryNodes
        aggregates - The aggregate list being built as we find AggregateNodes
        Returns:
        The new top of the expression tree.
        Throws:
        StandardException - Thrown on error
      • isSameNodeKind

        boolean isSameNodeKind​(ValueNode o)
        Description copied from class: ValueNode
        Some node classes represent several logical node types (to reduce footprint), which we call kinds. This means that implementations of ValueNode.isEquivalent(org.apache.derby.impl.sql.compile.ValueNode) cannot always just use instanceof to check if the other node represents the same kind. Hence this method needs to be overridden by all node classes that represent several kinds. This default implementation does not look at kinds. It is only called from implementations of isEquivalent.
        Overrides:
        isSameNodeKind in class UnaryOperatorNode
        Parameters:
        o - The other value node whose kind we want to compare with.
        Returns:
        true if this and o represent the same logical node type, i.e. kind.