@Override
  public void analyzeInternal(ASTNode root) throws SemanticException {
    if (root.getChildCount() == 0) {
      console.printError("Activate a resource plan to enable workload management!");
      return;
    }

    String resourcePlanName = unescapeIdentifier(root.getChild(0).getText());

    boolean enable = false;
    boolean activate = false;
    boolean replace = false;

    for (int i = 1; i < root.getChildCount(); ++i) {
      Tree child = root.getChild(i);
      switch (child.getType()) {
      case HiveParser.TOK_ACTIVATE:
        activate = true;
        if (child.getChildCount() > 1) {
          throw new SemanticException("Expected 0 or 1 arguments " + root.toStringTree());
        } else if (child.getChildCount() == 1) {
          if (child.getChild(0).getType() != HiveParser.TOK_REPLACE) {
            throw new SemanticException("Incorrect syntax " + root.toStringTree());
          }
          replace = true;
        }
        break;
      case HiveParser.TOK_ENABLE:
        enable = true;
        break;
      case HiveParser.TOK_REPLACE:
        replace = true;
        break;
      default:
        throw new SemanticException("Unexpected token in alter resource plan statement: " + child.getType());
      }
    }

    AlterResourcePlanEnableDesc desc = new AlterResourcePlanEnableDesc(resourcePlanName, enable, activate, replace);
    Task<DDLWork> task = TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc));
    rootTasks.add(task);

    DDLUtils.addServiceOutput(conf, getOutputs());
  }
Analyzer for enable resource plan commands.
ql/src/java/org/apache/hadoop/hive/ql/ddl/workloadmanagement/resourceplan/alter/enable/AlterResourcePlanEnableAnalyzer.java