@Override
  public void install() {
    // Upgrade the metastore to latest by running explicitly a script.
    String hiveSchemaVer = MetaStoreSchemaInfoFactory.get(new Configuration()).getHiveSchemaVersion();
    try (InputStream script = PostgresTPCDS.class.getClassLoader()
        .getResourceAsStream("sql/postgres/upgrade-3.1.3000-to-" + hiveSchemaVer + ".postgres.sql")) {
      new MetastoreSchemaTool().runScript(
          buildArray(
              "-upgradeSchema",
              "-dbType", getDbType(),
              "-userName", getHiveUser(),
              "-passWord", getHivePassword(),
              "-url", getJdbcUrl(),
              "-driver", getJdbcDriver()),
          script);
    } catch (IOException exception) {
      throw new UncheckedIOException(exception);
    }
  }
JUnit TestRule for Postgres metastore with TPCDS schema and stat information.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/dbinstall/rules/PostgresTPCDS.java