Class AlterCommandHandler

java.lang.Object
dev.frostlake.executor.commands.AlterCommandHandler
All Implemented Interfaces:
CommandHandler

public class AlterCommandHandler extends Object implements CommandHandler
Handles ALTER <object-type> … statements for DATABASE / SCHEMA / MASKING & ROW ACCESS POLICY / TABLE / VIEW / STREAM / TASK / PIPE / WAREHOUSE / STAGE / USER / ROLE / SESSION / TAG, extracted verbatim from SQLCommandVisitor.visitAlterStatement(dev.frostlake.parser.FrostlakeParser.AlterStatementContext). Leaf object types the visitor historically routed to the DDL side (FILE FORMAT / FUNCTION / PROCEDURE / DYNAMIC TABLE / MATERIALIZED VIEW / SEQUENCE) are still forwarded to DDLCommandHandler.handleAlterStatement(dev.frostlake.parser.FrostlakeParser.AlterStatementContext). Parse-text extraction (getText, extractStringLiteral, getOriginalText) and the shared engine helpers (parseDataType, parseLiteral, resolveCurrentSchema) are reached through the visitor back-reference so their exact original behavior is preserved; the task scheduler is read live via SQLCommandVisitor.getTaskScheduler() (it is wired onto the visitor post-construction).
  • Constructor Details

    • AlterCommandHandler

      public AlterCommandHandler(Catalog catalog, QueryExecutor queryExecutor, SQLCommandVisitor visitor, DDLCommandHandler ddlHandler)
      Wires the handler to the engine collaborators every ALTER branch needs.
      Parameters:
      catalog - the metastore catalog whose objects the ALTER actions mutate
      queryExecutor - the engine's query executor, for session state and security checks
      visitor - back-reference to the visitor's shared parse-text and type helpers (the task scheduler is read through it live, as it is wired on post-construction)
      ddlHandler - the DDL-side handler that still owns the forwarded leaf object types
  • Method Details

    • getCatalog

      public Catalog getCatalog()
      Description copied from interface: CommandHandler
      Get catalog instance
      Specified by:
      getCatalog in interface CommandHandler
      Returns:
      the engine's metastore catalog, holding the objects this handler reads and mutates
    • getQueryExecutor

      public QueryExecutor getQueryExecutor()
      Description copied from interface: CommandHandler
      Get query executor instance
      Specified by:
      getQueryExecutor in interface CommandHandler
      Returns:
      the engine's query executor, for handlers that run nested queries or need session state
    • handle

      Dispatches an ALTER <object-type> … statement on the object-type keyword in the parse tree and applies the requested action (RENAME / SET / UNSET / COMMENT / SUSPEND / RESUME / column and constraint changes, …) to the catalog object, after the owner/ALTER-privilege check. IF EXISTS turns a missing target into a silent success instead of an error; leaf object types the visitor historically routed to the DDL side are forwarded to DDLCommandHandler.handleAlterStatement(dev.frostlake.parser.FrostlakeParser.AlterStatementContext).
      Parameters:
      ctx - the ALTER statement's parse tree
      Returns:
      null for the branches handled here (the executor renders the standard status result), or the DDL handler's result for a forwarded object type