@Override
  public PartitionInfo createPartitionIfNotExists(final List<String> partitionValues) throws StreamingException {
    String partLocation = null;
    String partName = null;
    boolean exists = false;

    try {
      Map<String, String> partSpec = Warehouse.makeSpecFromValues(tableObject.getPartitionKeys(), partitionValues);

      Path location = new Path(tableObject.getDataLocation(), Warehouse.makePartPath(partSpec));
      location = new Path(Utilities.getQualifiedPath(conf, location));
      partLocation = location.toString();
      partName = Warehouse.makePartName(tableObject.getPartitionKeys(), partitionValues);
      Partition partition =
          org.apache.hadoop.hive.ql.metadata.Partition.createMetaPartitionObject(tableObject, partSpec, location);

      if (getMSC() == null) {
        // We assume it doesn't exist if we can't check it
        // so the driver will decide
        return new PartitionInfo(partName, partLocation, false);
      }

      getMSC().add_partition(partition);
      if (LOG.isDebugEnabled()) {
        LOG.debug("Created partition {} for table {}", partName,
            tableObject.getFullyQualifiedName());
      }
    } catch (AlreadyExistsException e) {
      exists = true;
    } catch (HiveException | TException e) {
      throw new StreamingException("Unable to creation partition for values: " + partitionValues + " connection: " +
        toConnectionInfoString(), e);
    }
    return new PartitionInfo(partName, partLocation, exists);
  }
Returning a streaming connection to hive.

@return - hive streaming connection
streaming/src/java/org/apache/hive/streaming/HiveStreamingConnection.java