code: public static String generateTableCopy(
        String inputTblName,
        String outputTblName,
        String inputDbName,
        String outputDbName,
        Optional<Map<String, String>> optionalPartitionDMLInfo) {
      Preconditions.checkArgument(StringUtils.isNotBlank(inputTblName));
      Preconditions.checkArgument(StringUtils.isNotBlank(outputTblName));
      Preconditions.checkArgument(StringUtils.isNotBlank(inputDbName));
      Preconditions.checkArgument(StringUtils.isNotBlank(outputDbName));
  
      StringBuilder dmlQuery = new StringBuilder();
  
      // Insert query
      dmlQuery.append(String.format("INSERT OVERWRITE TABLE `%s`.`%s` %n", outputDbName, outputTblName));
  
      if (optionalPartitionDMLInfo.isPresent() && optionalPartitionDMLInfo.get().size() > 0) {
        // Partition details
        dmlQuery.append(partitionKeyValues(optionalPartitionDMLInfo));
      }
  
      dmlQuery.append(String.format("SELECT * FROM `%s`.`%s`", inputDbName, inputTblName));
      if (optionalPartitionDMLInfo.isPresent()) {
        if (optionalPartitionDMLInfo.get().size() > 0) {
          dmlQuery.append(" WHERE ");
          String partitionsAndValues = optionalPartitionDMLInfo.get().entrySet().stream()
              .map(e -> "`" + e.getKey() + "`='" + e.getValue() + "'")
              .collect(joining(" AND "));
          dmlQuery.append(partitionsAndValues);
        }
      }
  
      return dmlQuery.toString();
    }
docs: Fills data from input table into output table.
  @param inputTblName input hive table name
  @param outputTblName output hive table name
  @param inputDbName input hive database name
  @param outputDbName output hive database name
  @param optionalPartitionDMLInfo input hive table's partition's name and value
  @return Hive query string