【问题标题】:Aggregate UDFs with Python in Redshift在 Redshift 中使用 Python 聚合 UDF
【发布时间】:2016-01-24 14:55:36
【问题描述】:

我设法在 AmazonRedshift 中使用 Python 编写了一些标量函数,即将一列或几列作为输入,并根据某些逻辑或转换返回单个值。

但是有没有办法在 UDF 中传递数字列(即列表)的所有值并计算这些值的统计信息,例如平均值或标准差?

【问题讨论】:

    标签: python amazon-web-services amazon-redshift udf


    【解决方案1】:

    文档说明只有标量 udf 函数是可能的(请参阅 http://docs.aws.amazon.com/redshift/latest/dg/user-defined-functions.html)。

    但是,如果值列表不是太大,您可以通过创建一个字符串标量 udf 来作弊,该字符串是 LISTAGG 函数执行的结果。

    例如:select udfSum(listagg(val,'|')) from table;

    见:http://docs.aws.amazon.com/redshift/latest/dg/r_LISTAGG.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-07
      • 2016-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多