private boolean isMaterializableCte(HiveRelMetadataQuery mq, RelNode cte) {
      final boolean checkFullAggregate = conf.getBoolVar(ConfVars.HIVE_CTE_MATERIALIZE_FULL_AGGREGATE_ONLY);
      ImmutableBitSet cteOutputColumns = ImmutableBitSet.range(cte.getRowType().getFieldCount());
      if (checkFullAggregate && !Boolean.TRUE.equals(mq.areColumnsAggregated(cte, cteOutputColumns))) {
        LOG.debug("Skipping CTE {} cause its not a full aggregate.", cte);
        return false;
      }
      if (HiveSqlTypeUtil.containsSqlType(cte.getRowType(), SqlTypeName.NULL)) {
        LOG.debug("Skipping CTE {} cause it contains untyped nulls", cte);
        return false;
      }
      return true;
    }
@return whether the specified cte fulfills all preconditions for materialization.
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java