简体   繁体   中英

Hive table sizes using Java/JDBC

Is it possible to find the sizes in GB of the hive tables using Java/jdbc? I don't want to depend on the hive warehouse folder in HDFS (as described in link ) as different tables may have different locations

Currently not be possible but it can be done .

To get file size you have to run on file system( HDFS) commands .

In case of RDMS data bases ie sql server have encapsulated file system commands in SYS views and SYS functions (DMF and DMVs) .

If some one write or develop such UDF it will be possible but Internally the UDF will be calling same comand.

If you are mention 'totalSize' from 'tblproperties' then it is possible with similar approach:

String driverName = "org.apache.hive.jdbc.HiveDriver";
String connectionURL = "jdbc:hive2://HOSTNAME:PORT/default";

try {
     Class.forName(driverName);
     Connection connection = DriverManager.getConnection( connectionURL, "", "");
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      System.exit(1);
    }

Statement stmt = connection.createStatement("show tblproperties TABLENAME");
ResultSet rs =  stmt.executeQuery(stmt);
while(rs.next()){
            //doWhatYouWant
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM