@Override
  public void ruleProductionSucceeded(RuleProductionEvent event) {
    if (event.isBefore() && LOG.isDebugEnabled()) {
      RelOptRuleCall call = event.getRuleCall();

      Arrays.stream(call.rels).forEach(rel ->
          LOG.debug(FULL, "call#{}: Full plan for rule input [rel#{}:{}]: {}", call.id, rel.getId(),
              rel.getRelTypeName(), System.lineSeparator() + RelOptUtil.toString(rel)));

      RelNode newRel = event.getRel();
      String description = newRel == null ? "null" : "rel#" + newRel.getId() + ":" + newRel.getRelTypeName();
      LOG.debug("call#{}: Rule [{}] produced [{}]", call.id, call.getRule(), description);
      if (newRel != null) {
        LOG.debug(FULL, "call#{}: Full plan for [{}]:{}", call.id, description,
            System.lineSeparator() + RelOptUtil.toString(newRel));
      }
    }
  }
Listener for logging useful debugging information on certain rule events.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/RuleEventLogger.java