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.
  • Field Details

  • Constructor Details

    • 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 Details

    • bindExpression

      ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, 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
    • invalidOperandType

      private void invalidOperandType() throws StandardException
      Throws:
      StandardException
    • generateExpression

      void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
      Do code generation for this unary operator.
      Overrides:
      generateExpression in class UnaryOperatorNode
      Parameters:
      acb - The ExpressionClassBuilder for the class we're generating
      mb - The method the expression will go into
      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.