You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查询Azure Databricks所有目录(含Hive元存储)中使用Liquid Clustering的表

检查Azure Databricks中使用Liquid Clustering的表

需求:排查Azure Databricks所有目录(包含旧版hive_metastore)下所有Schema中使用Liquid Clustering的表。

问题限制:微软文档显示Unity Catalog系统表未存储Liquid Clustering相关信息,且使用DESCRIBE DETAIL查询非Delta外部表时会触发FileAlreadyExistsException错误。

以下是解决该问题的Python脚本:

%python

tables = spark.sql("SELECT * FROM system.INFORMATION_SCHEMA.tables WHERE table_schema != 'information_schema'")\
.select("table_catalog","table_schema","table_name")\
.rdd.map(lambda x:(x.table_catalog,x.table_schema,x.table_name)).collect()
clustered_tables = []

for i in tables:
    df_object_type = spark.sql(f"SHOW TBLPROPERTIES {i[0]}.{i[1]}.{i[2]}")
    df_cluster_columns = df_object_type.where(df_object_type.key == 'delta.liquid.clusteringColumns')
    cluster_col = df_cluster_columns.rdd.map(lambda x: x["value"]).collect()

    # 以下为原报错的方法,已注释
    # cluster_col = spark.sql(f"DESCRIBE DETAIL {i[0]}.{i[1]}.{i[2]}")\
    # .select("clusteringColumns")\
    # .rdd.map(lambda x:x.clusteringColumns).collect()[0]

    if len(cluster_col) != 0:
        clustered_tables.append(f"{i[0]}.{i[1]}.{i[2]}")

print(clustered_tables)

感谢JayashankarGS提供的思路,该方案可有效解决问题。

内容的提问来源于stack exchange,提问作者Ken Masters

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 21:55:12