hive启用LAST_ACCESS_TIME(访问时间)

1.hive-site.xml 的 Hive 服务高级配置代码段(安全阀)中添加2个参数:

hive.security.authorization.sqlstd.confwhitelist=hive.exec.pre.hooks

hive.exec.pre.hooks=org.apache.hadoop.hive.ql.hooks.UpdateInputAccessTimeHook$PreExec

2.重启hive即可

<property>
	<name>hive.security.authorization.sqlstd.confwhitelist</name>
	<value>hive.exec.pre.hooks</value>
</property>

<property>
	<name>hive.exec.pre.hooks</name>
	<value>org.apache.hadoop.hive.ql.hooks.UpdateInputAccessTimeHook$PreExec</value>
</property>
SELECT *
FROM TBLS
WHERE TBL_NAME = 'student3';

在这里插入图片描述

show table extended like student3;
hive (default)>
              >
              >
              >
              >
              > show table extended like student3;
OK
tab_name
tableName:student3
owner:atguigu
location:hdfs://hadoop102:8020/user/hive/warehouse/student3
inputformat:org.apache.hadoop.mapred.TextInputFormat
outputformat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
columns:struct columns { i32 id, string name}
partitioned:false
partitionColumns:
totalNumberFiles:1
totalFileSize:7
maxFileSize:7
minFileSize:7
lastAccessTime:1686048455210
lastUpdateTime:1685972721193

Time taken: 0.216 seconds, Fetched: 15 row(s)
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;

/**

 */
public class Test2 {

    public static void main(String[] args) throws Exception {

        HiveConf hiveConf = new HiveConf();
        MetastoreConf.setVar(hiveConf,MetastoreConf.ConfVars.THRIFT_URIS ,"thrift://hadoop102:9083" );

        HiveMetaStoreClient hiveClient = new HiveMetaStoreClient(hiveConf);

        Table aaa = hiveClient.getTable("default", "student3");
        int lastAccessTime = aaa.getLastAccessTime();
        System.out.println("lastAccessTime = " + lastAccessTime);

        System.out.println(aaa.getTableName());

//        String schema = "blending";
//        HCatClient client = HCatalogClient.getClient(null);
//        List<String> tables = client.listTableNamesByPattern(schema, "*");
//        for(String table : tables) {
//            HCatTable hTable = client.getTable(schema, table);
//            System.out.println("Table name is :" +hTable.getTableName());
//            System.out.println("Input file format is:"+hTable.getInputFileFormat());
//            System.out.println("Output file format is:"+hTable.getOutputFileFormat());
//        }
//
//        HCatCli hCatCli = new HCatCli();



    }


}

结果:

lastAccessTime = 1686049690

查询分区信息:

show table extended like dim_user_zip PARTITION(dt='9999-12-31');

在这里插入图片描述
在这里插入图片描述
查询总大小:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值