public static Properties mergeUserConnectionPropertiesAndBeelineSite(
      Properties userConnectionProperties, JdbcConnectionParams jdbcConnectionParams)
      throws BeelineHS2ConnectionFileParseException {
    Properties mergedConnectionProperties = new Properties();

    userConnectionProperties.setProperty(HS2ConnectionFileParser.URL_PREFIX_PROPERTY_KEY,
        "jdbc:hive2://");

    // Host
    String host =
        getMergedProperty(userConnectionProperties, jdbcConnectionParams.getSuppliedURLAuthority(),
            HS2ConnectionFileParser.HOST_PROPERTY_KEY, null);
    if (host != null) {
      mergedConnectionProperties.setProperty(HS2ConnectionFileParser.HOST_PROPERTY_KEY, host);
    }

    // Database
    String defaultDB = getMergedProperty(userConnectionProperties, jdbcConnectionParams.getDbName(),
        HS2ConnectionFileParser.DEFAULT_DB_PROPERTY_KEY, "default");
    mergedConnectionProperties.setProperty(HS2ConnectionFileParser.DEFAULT_DB_PROPERTY_KEY,
        defaultDB);

    // hive conf
    String hiveConfProperties = getMergedPropertiesString(userConnectionProperties,
        HS2ConnectionFileParser.HIVE_CONF_PROPERTY_KEY, jdbcConnectionParams.getHiveConfs());
    if (!hiveConfProperties.isEmpty()) {
      mergedConnectionProperties.setProperty(HS2ConnectionFileParser.HIVE_CONF_PROPERTY_KEY,
          hiveConfProperties);
    }

    // hive vars
    String hiveVarProperties = getMergedPropertiesString(userConnectionProperties,
        HS2ConnectionFileParser.HIVE_VAR_PROPERTY_KEY, jdbcConnectionParams.getHiveVars());
    if (!hiveVarProperties.isEmpty()) {
      mergedConnectionProperties.setProperty(HS2ConnectionFileParser.HIVE_VAR_PROPERTY_KEY,
          hiveVarProperties);
    }

    // session vars
    for (Map.Entry<String, String> entry : jdbcConnectionParams.getSessionVars().entrySet()) {
      mergedConnectionProperties.setProperty(entry.getKey(), entry.getValue());
    }
    if (userConnectionProperties != null) {
      for (String propName : userConnectionProperties.stringPropertyNames()) {
        mergedConnectionProperties.setProperty(propName,
            userConnectionProperties.getProperty(propName));
      }
    }
    return mergedConnectionProperties;
  }
Merge the connection properties read from beeline-hs2-connection.xml with the
JdbcConnectionParams extracted from the jdbc url specified in beeline.xml

@param userConnectionProperties
@param jdbcConnectionParams
@return
@throws BeelineHS2ConnectionFileParseException
beeline/src/java/org/apache/hive/beeline/hs2connection/HS2ConnectionFileUtils.java