Class MeasureScope

java.lang.Object
org.apache.calcite.sql.validate.DelegatingScope
org.apache.calcite.sql.validate.MeasureScope
All Implemented Interfaces:
SqlValidatorScope

public class MeasureScope extends DelegatingScope
Scope for resolving identifiers within a SELECT item that is annotated "AS MEASURE".

Scope includes the identifiers of SELECT plus all aliases. This allows measures to reference each other and also reference other SELECT items.

  • Method Details

    • getNode

      public SqlNode getNode()
      Description copied from interface: SqlValidatorScope
      Returns the root node of this scope. Never null.
    • validateExpr

      public void validateExpr(SqlNode expr)
      Description copied from interface: SqlValidatorScope
      Performs any scope-specific validation of an expression. For example, an aggregating scope requires that expressions are valid aggregations. The expression has already been validated.
      Specified by:
      validateExpr in interface SqlValidatorScope
      Overrides:
      validateExpr in class DelegatingScope
    • resolveColumn

      public @Nullable RelDataType resolveColumn(String name, SqlNode ctx)
      Description copied from interface: SqlValidatorScope
      Resolves a single identifier to a column, and returns the datatype of that column.

      If it cannot find the column, returns null. If the column is ambiguous, throws an error with context ctx.

      Specified by:
      resolveColumn in interface SqlValidatorScope
      Overrides:
      resolveColumn in class DelegatingScope
      Parameters:
      name - Name of column
      ctx - Context for exception
      Returns:
      Type of column, if found and unambiguous; null if not found
    • lookupMeasure

      public @Nullable SqlNode lookupMeasure(String name)
    • fullyQualify

      public SqlQualified fullyQualify(SqlIdentifier identifier)
      Description copied from class: DelegatingScope
      Converts an identifier into a fully-qualified identifier. For example, the "empno" in "select empno from emp natural join dept" becomes "emp.empno".

      If the identifier cannot be resolved, throws. Never returns null.

      Specified by:
      fullyQualify in interface SqlValidatorScope
      Overrides:
      fullyQualify in class DelegatingScope
      Returns:
      A qualified identifier, never null