Class CastExpression

java.lang.Object
dev.frostlake.executor.expressions.CastExpression
All Implemented Interfaces:
Expression

public class CastExpression extends Object implements Expression
Represents a type cast (e.g., CAST(x AS INTEGER), x::VARCHAR). When tryMode is set (TRY_CAST), a failed conversion yields NULL instead of raising an error.

A PARAMETERIZED target whose parameters decide the cast's legality and result — a STRUCTURED type (OBJECT(x VARCHAR), ARRAY(INT), MAP(k,v)) or a VECTOR(FLOAT|INT, n) — is carried as a parsed DataType alongside the target-type text, together with the optional RENAME FIELDS / ADD FIELDS modifier. Those parameters must survive from the parse tree rather than being re-derived from the (whitespace-stripped) target text.

  • Constructor Details

  • Method Details

    • getExpression

      public Expression getExpression()
    • getTargetType

      public String getTargetType()
    • isTryMode

      public boolean isTryMode()
    • getDeclaredTarget

      public DataType getDeclaredTarget()
      The parsed target type when its PARAMETERS matter (a structured type, or a VECTOR(t, n)), or null when the plain target-type text says everything.
    • getFieldsModifier

      public CastFieldsModifier getFieldsModifier()
      The RENAME FIELDS / ADD FIELDS modifier, never null.
    • getPosition

      public SourcePosition getPosition()
      Where the cast was written, relative to its fragment — the :: of the shorthand, the CAST or TRY_CAST keyword otherwise — or null for a cast the engine built itself. A refusal of the cast as a whole is positioned there: live points v::VECTOR(INT,3) at the ::.
    • setPosition

      public void setPosition(SourcePosition position)
    • accept

      public <T> T accept(ExpressionVisitor<T> visitor)
      Description copied from interface: Expression
      Accept a visitor for the visitor pattern
      Specified by:
      accept in interface Expression
    • toString

      public String toString()
      Overrides:
      toString in class Object