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

Snowflake视图调用存储过程报“未知表函数”错的解决方案

问题原因

你遇到的报错是因为存储过程(PROCEDURE)不能在视图中当作表函数调用。Snowflake的视图仅支持使用表函数(TABLE FUNCTION)通过TABLE()语法嵌入查询,而你定义的get_state_based_on_temp是存储过程,不属于表函数范畴,所以视图无法识别它。

解决方案

把原存储过程改成表函数即可,修改后的代码如下:

create or replace function get_state_based_on_temp(temp_value integer)
returns table(state string)
language sql
as
$$
    select state from temp_table1 where temp <= :temp_value
$$;

之后再执行你原来的视图创建语句就可以正常运行了:

create or replace view tem_result_view as 
select doc.d as date_in, view_temp.state 
from temp_table1 doc, table(get_state_based_on_temp(69)) as view_temp;
补充说明

直接用call get_state_based_on_temp(70);能成功,是因为CALL是Snowflake专门用于执行存储过程的语法,和视图的查询语法规则不同,所以存储过程可以通过CALL正常调用,但无法在视图里用表函数的方式调用。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 22:50:31