Hive Metastore中的上次访问时间更新

时间:2020-02-24 23:44:18

标签: apache-spark pyspark hive apache-spark-sql

我在hive console / .hiverc文件中使用了此属性,每当查询该表时,它都会更新hive metastore的TBLS表中的LAST_ACCESS_TIME列,并且我能够查询该列。

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

但是,当我使用spark-sql或spark-shell时,它似乎无法正常工作,并且hive-metastore中的时间戳没有更新。

简单地触发-

df = spark.sql(“从db.sometable中选择*”) df.show()

我已经在安装位置/ etc / hive / conf和/ etc / spark / conf的hive-site.xml中设置了以上钩子。

1 个答案:

答案 0 :(得分:1)

您的代码可能会跳过某些 Hive 集成。我记得要获得更多 Hive-ish 集成,您需要引入 HiveContext,如下所示:

from pyspark import SparkContext, SparkConf, HiveContext

if __name__ == "__main__":

  # create Spark context with Spark configuration
  conf = SparkConf().setAppName("Data Frame Join")
  sc = SparkContext(conf=conf)
  sqlContext = HiveContext(sc)
  df_07 = sqlContext.sql("SELECT * from sample_07")

https://docs.cloudera.com/runtime/7.2.7/developing-spark-applications/topics/spark-sql-example.html

希望能帮到你