[英]Hive table sizes using Java/JDBC
Currently not be possible but it can be done . 目前尚不可能,但可以完成。
To get file size you have to run on file system( HDFS) commands . 要获取文件大小,您必须在文件系统(HDFS)命令上运行。
In case of RDMS data bases ie sql server have encapsulated file system commands in SYS views and SYS functions (DMF and DMVs) . 在RDMS数据库的情况下,即sql server在SYS视图和SYS函数(DMF和DMV)中具有封装的文件系统命令。
If some one write or develop such UDF it will be possible but Internally the UDF will be calling same comand. 如果有人编写或开发这样的UDF是可能的,但是内部UDF将调用相同的命令。
If you are mention 'totalSize' from 'tblproperties' then it is possible with similar approach: 如果从“ tblproperties”中提到“ totalSize”,则可以使用类似的方法:
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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.