我正在使用 Javascript 创建一个 Snowflake 存储过程。我收到该过程抛出的 SQL 异常,提示“缺少列规范”。堆栈跟踪指向这部分:var cmd_outputCreation = `CREATE OR REPLACE TABLE ${TBL_OUTPUT} AS( SELECT A.*, B.RESULT[0], B.RESULT[1] FROM( SELECT ${API_FUNCTION}(joined.*) AS result FROM ( SELECT ${c_id}, ${c_location_name}, ${c_street_address}, ${c_city}, ${c_region}, ${c_postal_code}, ${c_latitude}, ${c_longitude}, ${c_country_code} FROM ${TBL_INPUT} ) AS joined ) AS B INNER JOIN ${TBL_INPUT} AS A ON A.RECID = B.RESULT[0] )`;var stmt_outputCreation = snowflake.createStatement( {sqlText: cmd_outputCreation} );var result_outputCreation = stmt_outputCreation.execute();但是,我在这里看不到任何错误。如果我在没有 SP 的情况下使用它,查询本身在 SQL 上运行(显然用实际的 SQL 表/列替换变量名称)我知道“缺少列规范”意味着“列没有名称”,但情况似乎并非如此。我在这里缺少什么?
1 回答
慕的地10843
TA贡献1785条经验 获得超8个赞
您需要为 B.RESULT[0] 和 B.RESULT[1] 指定别名以赋予列唯一的名称:
create temp table bar as select array_construct(1, 2) as b;
-- This gets missing column specification
create temp table foo as select b[0], b[1] from bar;
-- This does not
create temp table foo as select b[0] as B0, b[1] as B1 from bar;
添加回答
举报
0/150
提交
取消