从metastore下降与损坏的元数据表

学习如何减少从metastore表包含的元数据。

写的亚当Pavlacka

去年发表在:2022年5月16日

问题

有时你不能删除一个表的数据砖UI。使用%的sqlspark.sql删除表不工作。

导致

中存储的元数据(表模式)metastore损坏。当您运行删除表命令,火花检查表是否存在或不删除表之前。从表的元数据损坏火花不能删除表和失败后例外。

% scala com.databricks.backend.common.rpc.DatabricksExceptions $ SQLExecutionException: org.apache.spark.sql。AnalysisException:元数据损坏

解决方案

使用蜂巢客户放弃表自蜂巢客户机不检查表存在像火花一样。删除一个表:

  1. 创建一个函数在蜂巢包。
    % org.apache.spark.sql scala包。蜂巢{org.apache.spark.sql.hive进口。HiveUtils org.apache.spark进口。SparkContext对象跑龙套{def dropTable (sc: SparkContext dbName:字符串,表名:字符串,ignoreIfNotExists: Boolean、清洗:布尔型):单位= {HiveUtils .newClientForMetadata (sc。getConf sc.hadoopConfiguration) .dropTable (ignoreIfNotExists dbName,表名,假)}}}
  2. 降低损坏表。
    % scala org.apache.spark.sql.hive进口。跑龙套跑龙套。dropTable (sc、“默认”、“my_table”,真的,真的)
这篇文章有用吗?