使用Python访问Snowflake查询历史时遇information_schema无效标识符错误
解决Snowflake Python执行查询历史报错的问题
问题根源
你写的information_schema.query_history()是错误的用法——Snowflake的全局查询历史表函数属于account_usage架构,而非information_schema。另外执行该函数需要对应权限,Python连接时的默认数据库/架构上下文也可能未正确匹配。
修复方案
- 使用正确的表函数路径,完整查询语句改为:
select * from table(account_usage.query_history()) - 确认当前用户拥有
ACCOUNT_USAGE架构的访问权限,无权限需联系管理员授予。 - 若仍报错,可显式指定数据库和架构:
select * from table(snowflake.account_usage.query_history())
补充选项
如果仅需查看当前会话的查询历史,可使用information_schema下的对应函数:
select * from table(information_schema.session_history())
内容的提问来源于stack exchange,提问作者panther93
相关产品推荐
相关产品推荐

