【问题标题】:How to get lastaltertimestamp from Hive table?如何从 Hive 表中获取 lastaltertimestamp?
【发布时间】:2017-02-24 00:15:00
【问题描述】:

Teradata 有lastaltertimestamp 的概念,这是最后一次对表执行alter table 命令。可以查询lastaltertimestamp。 Hive 是否有类似的值可以查询?

hdfs dfs -ls /my/hive/file 返回的时间戳不反映alter table 命令,因此alter table 不得修改支持 Hive 文件的文件。 describe formatted 也不提供 last-alter-timestamp。 谢谢

【问题讨论】:

    标签: hadoop hive teradata alter-table


    【解决方案1】:

    Hive 将元数据存储到数据库中,因此文件永远不会被修改。 AFAIK 在 HIVE 中跟踪的唯一时间戳是 transient_lastDdlTime

    创建表时,它是创建表时的时间戳。 当任何 DDL 完成时,它是最后一个 DDL 时间

    您仍然可以将自定义属性添加到表中,以便跟踪您想要的任何内容。

    【讨论】:

      【解决方案2】:

      "transient_lastDdlTime" 是告诉 Hive 表的最后更改时间的属性。为了获取它以及 Hive 表的其他元数据,您可以运行以下查询:

      describe formatted <table_name>;
      

      这个输出:

      Database:               xxxxxxxxx
      Owner:                  xxxxxxxxx
      CreateTime:             Tue Jan xx 06:58:21 IST xxxx
      LastAccessTime:         UNKNOWN
      Retention:              0
      Location:               xxxxxxxxx
      Table Type:             xxxxxxxxx
      Table Parameters:   
          numFiles                xxxxxxxxx
          numRows                 xxxxxxxxx
          rawDataSize             xxxxxxxxx
          totalSize               xxxxxxxxx
          transient_lastDdlTime   1517424154
      
      # Storage Information
      SerDe Library:          xxxxxxxxx
      InputFormat:            xxxxxxxxx
      OutputFormat:           xxxxxxxxx
      Compressed:             xxxxxxxxx
      Num Buckets:            xxxxxxxxx
      Bucket Columns:         xxxxxxxxx
      Sort Columns:           xxxxxxxxx
      Storage Desc Params:
          serialization.format    xxxxxxxxx
      

      输出的transient_lastDdlTime是纪元格式。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-26
        • 1970-01-01
        相关资源
        最近更新 更多