Class ProjectOperator

java.lang.Object
dev.frostlake.executor.operators.ProjectOperator
All Implemented Interfaces:
Operator

public class ProjectOperator extends Object implements Operator
PROJECT operator - projects (selects) specific columns from rows. This operator handles the SELECT list evaluation for non-aggregate queries. It evaluates expressions for each row and creates new rows with only the selected columns.
  • Constructor Details

    • ProjectOperator

      public ProjectOperator(List<String> projectionExpressions, List<String> columnAliases, RowExpressionEvaluator expressionEvaluator)
      Create a PROJECT operator.
      Parameters:
      projectionExpressions - List of expressions to evaluate (e.g., "name", "age + 1", "COUNT(*)")
      columnAliases - List of column aliases (null entries allowed for no alias)
      expressionEvaluator - Evaluator to evaluate expressions on a row
    • ProjectOperator

      public ProjectOperator(List<String> projectionExpressions, List<String> columnAliases, RowExpressionEvaluator expressionEvaluator, Map<String,Object> lateralAliasSink)
      Create a PROJECT operator with lateral column-alias support.
      Parameters:
      lateralAliasSink - a map SHARED with expressionEvaluator's lateral context: as each aliased SELECT item is evaluated left-to-right, its (uppercased) alias → value is written here so a LATER item in the same SELECT list can reference it (Snowflake lateral column aliases). Cleared per input row. When null, no lateral-alias values are exposed to later items (only the exact-whole-item-is-an-alias shortcut applies).
    • ProjectOperator

      public ProjectOperator(List<String> projectionExpressions, List<String> columnAliases, RowExpressionEvaluator expressionEvaluator, Map<String,Object> lateralAliasSink, Map<String,Object> baseBindings)
      As ProjectOperator(List, List, RowExpressionEvaluator, Map), additionally carrying the OUTER bindings of a LATERAL / correlated execution.
      Parameters:
      baseBindings - outer-row name → value bindings re-seeded into lateralAliasSink after its per-row reset, so a SELECT item may reference an outer alias by qualified name (SELECT fa.asset_key inside LEFT JOIN LATERAL (…)) — the sink is the evaluator's lateral context, and its per-row clear would otherwise drop them. Item aliases fill in later, so they shadow a same-named outer key; null when the query does not execute under an outer row.
  • Method Details

    • setExpressionOrigins

      public void setExpressionOrigins(List<SourcePosition> expressionOrigins)
      Where each projection item began in the statement, index-aligned with the expressions. Null entries are synthesised items (star expansion), which nobody wrote and which therefore report no position.
    • execute

      public List<Row> execute(List<Row> input, OperatorContext context)
      Description copied from interface: Operator
      Execute this operator on the input rows.
      Specified by:
      execute in interface Operator
      Parameters:
      input - The input rows from the previous operator
      context - The execution context containing table metadata and other information
      Returns:
      The output rows after applying this operator
    • getDescription

      public String getDescription()
      Description copied from interface: Operator
      Get a description of this operator for debugging/logging.
      Specified by:
      getDescription in interface Operator
      Returns:
      A human-readable description of the operator