如何按名称访问 redshift SQL 函数中的输入变量

how to access input variables in redshift SQL function by name

我正在尝试创建一个 Redshift SQL 函数并尝试通过名称访问输入变量。

create or replace 
function sql_udf_test (inp1 int, inp2 int)
 returns int
stable
as $$
select inp1+inp2
$$ language sql;

错误

SQL Error [500310] [42703]: Amazon Invalid operation: column "inp1" does not exist;

然而,当我尝试通过其索引访问输入变量时,它工作正常。

create or replace 
function sql_udf_test (inp1 int, inp2 int)
 returns int
stable
as $$
select +
$$ language sql;

select sql_udf_test(1, 2);

输出:

3

任何建议,可能是我犯了一些初学者错误。

amazon documentation中明确提到,在SQLUDF中,你必须使用$1,$2,等等来引用函数的输入参数和参数的名称即可在 Python UDF 中使用。

In a Python UDF, refer to arguments using the argument names. In a SQL UDF, refer to arguments using , , and so on, based on the order of the arguments in the argument list.