Class NamedExpression

All Implemented Interfaces:
NamedWriteable, Writeable, Resolvable
Direct Known Subclasses:
Alias, Attribute, UnresolvedNamedExpression

public abstract class NamedExpression extends Expression implements NamedWriteable
An expression that has a name. Named expressions can be used as a result (by converting to an attribute).
  • Constructor Details

  • Method Details

    • name

      public String name()
    • id

      public NameId id()
    • synthetic

      public boolean synthetic()
      Synthetic named expressions are not user defined and usually created during optimizations and substitutions, e.g. when turning ... | STATS x = avg(2*field) into ... | EVAL $$synth$attribute = 2*field | STATS x = avg($$synth$attribute).
    • toAttribute

      public abstract Attribute toAttribute()
      Try to return either this if it is an Attribute, or a ReferenceAttribute to it otherwise. Return an UnresolvedAttribute if this is unresolved.
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Node<Expression>
    • hashCode

      public final int hashCode(boolean ignoreIds)
    • innerHashCode

      protected int innerHashCode(boolean ignoreIds)
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Node<Expression>
    • equals

      public final boolean equals(Object o, boolean ignoreIds)
      Polymorphic equality is a pain and can be slow. This shortcuts this == o and class checks (important when we expect only a few non-equal objects).

      For the actual equality check override innerEquals(Object, boolean) instead.

      We also provide the option to ignore NameIds in the equality check, which helps e.g. when creating named expressions while avoiding duplicates, or when attaching failures to unresolved attributes (see Failure.equals). Some classes will always ignore ids, irrespective of the parameter passed here.

    • innerEquals

      protected boolean innerEquals(Object o, boolean ignoreIds)
      The actual equality check, after shortcutting this == o and class checks.
    • toString

      public String toString()
      Overrides:
      toString in class Expression
    • nodeString

      public String nodeString()
      Overrides:
      nodeString in class Node<Expression>