雪花秀 cluster_by

snowflake show tables with cluster_by

我可以使用 show tables in <database name> 来显示数据库中的所有 table。 返回的结果显示 table 是否启用了集群 - 显示 cluster_by 列。 有没有办法取回在 cluster_by 中具有价值的所有 table 的列表?

show-tables 的 documentation 仅显示:

SHOW [ TERSE ] TABLES [ HISTORY ] [ LIKE '<pattern>' ]
                                  [ IN { ACCOUNT | DATABASE [ <db_name> ] | SCHEMA [ <schema_name> ] } ]
                                  [ STARTS WITH '<name_string>' ]
                                  [ LIMIT <rows> [ FROM '<name_string>' ] ]

你随时可以问INFORMATION_SCHEMA:

SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, CLUSTERING_KEY 
  FROM INFORMATION_SCHEMA.TABLES
 WHERE CLUSTERING_KEY IS NOT NULL;

或使用RESULT_SCAN

SHOW TABLES IN DATABASE TEST;

SELECT * 
FROM TABLE(result_scan(last_query_id())) 
WHERE "cluster_by" <> '';

参考:INFORMATION SCHEMA TABLES VIEW, RESULT_SCAN