private void getSkewedByClause(StringBuilder query) {
    if (sourceTab != null) {
      boolean isFirst; // Stored as directories. We don't care about the skew otherwise.
      if (sourceTab.getSd().isStoredAsSubDirectories()) {
        SkewedInfo skewedInfo = sourceTab.getSd().getSkewedInfo();
        if (skewedInfo != null && !skewedInfo.getSkewedColNames().isEmpty()) {
          query.append(" SKEWED BY (").append(StringUtils.join(skewedInfo.getSkewedColNames(), ", ")).append(") ON ");
          isFirst = true;
          for (List<String> colValues : skewedInfo.getSkewedColValues()) {
            if (!isFirst) {
              query.append(", ");
            }
            isFirst = false;
            query.append("('").append(StringUtils.join(colValues, "','")).append("')");
          }
          query.append(") STORED AS DIRECTORIES");
        }
      }
    }
  }
Part of Create operation. Insert-only compaction tables copy source tables.
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactionQueryBuilderForInsertOnly.java