Class OrderByScope

Object
gudusoft.gsqlparser.resolver2.scope.AbstractScope
gudusoft.gsqlparser.resolver2.scope.OrderByScope
All Implemented Interfaces:
IScope

public class OrderByScope extends AbstractScope
Scope for ORDER BY clause.

Visibility rules: - Can access SELECT list columns (by name or alias) - Can access SELECT list positional references (ORDER BY 1, 2, etc.) - In some databases, can also access columns from FROM clause directly - Can reference aggregate functions in SELECT list

Example:

 SELECT department, COUNT(*) as emp_count
 FROM employees
 GROUP BY department
 ORDER BY emp_count DESC,  -- Can use SELECT list alias
          department ASC,  -- Can use SELECT list column
          1                -- Can use positional reference
 

The ORDER BY scope primarily delegates to SELECT scope, but may also access FROM scope depending on database vendor.

  • Constructor Details

  • Method Details

    • setSelectScope

      public void setSelectScope(IScope selectScope)
      Set the SELECT scope for alias resolution. ORDER BY can reference SELECT list columns and aliases.
      Parameters:
      selectScope - the SELECT scope
    • setFromScope

      public void setFromScope(IScope fromScope)
      Set the FROM scope for column resolution. In some databases, ORDER BY can reference FROM clause columns directly.
      Parameters:
      fromScope - the FROM scope
    • getSelectScope

      Get the SELECT scope.
      Returns:
      the SELECT scope, or null if not set
    • getFromScope

      public IScope getFromScope()
      Get the FROM scope.
      Returns:
      the FROM scope, or null if not set
    • getOrderByNode

    • toString

      public String toString()
      Overrides:
      toString in class AbstractScope