@Override
  public boolean matches(final RelOptRuleCall call) {
    TableScan scan = call.rel(0);
    List<String> tableName = scan.getTable().getQualifiedName();
    if (spools.contains(tableName.toString())) {
      return false;
    }
    return config.getTableOccurrences().getOrDefault(tableName, 0) > config.referenceThreshold();
  }
Track created spools to avoid introducing more than one.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/TableScanToSpoolRule.java