CREATE OR REPLACE FUNCTION f_stop_distance (Float, Float, Float, Float) /* This calculates distance in meters between two sets of lat and long */
RETURNS FLOAT
IMMUTABLE
AS $$
SELECT
2 * 6373000 * ASIN( SQRT( ( SIN( RADIANS(($3 - $1) / 2) ) ) ^ 2 + COS(RADIANS($1)) * COS(RADIANS($3)) * (SIN(RADIANS(($4 - $2) / 2))) ^ 2))
$$ LANGUAGE sql
;
以上是我用于计算两个纬长对之间距离的代码段。我的问题是我也可以在ETL查询中使用以上内容吗?
注意:我不是超级用户,也不会被授予超级用户权限。
更新:我已经尝试过在ETL中执行。这是我收到的错误:
2019-02-20 03:19:56,594 ERROR ExtractAdapterForRedshiftWithUnload prepareS3Dataset():609 - Error Code from SQL state 42501
org.postgresql.util.PSQLException: ERROR: must be owner of function f_stop_distance
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2270)