Amazon web services AWS雅典娜-应用过滤器,然后计算百分位数
我正在使用AWS Athena计算一些指标。我有这样一个数据集:Amazon web services AWS雅典娜-应用过滤器,然后计算百分位数,amazon-web-services,amazon-athena,presto,Amazon Web Services,Amazon Athena,Presto,我正在使用AWS Athena计算一些指标。我有这样一个数据集: 课时数 0 10 -1 10 2. -10 10 我试图计算这些值的百分位数,但只计算有效值的子集。有效值是sessionnumber>1,因此我尝试了以下方法: with testfun AS (SELECT filter(array_agg(sessionnumber), x -> x >= 1) as validvalues FROM "mydate") SELECT (percent
课时数
0
10
-1
10
2.
-10
10
我试图计算这些值的百分位数,但只计算有效值的子集。有效值是sessionnumber>1
,因此我尝试了以下方法:
with testfun AS
(SELECT filter(array_agg(sessionnumber), x -> x >= 1) as validvalues
FROM "mydate")
SELECT (percentiles(validvalues, 0.25) FROM testfun
但我得到了以下错误:
SYNTAX_ERROR: line 17:10: Unexpected parameters (array(integer), double) for function approx_percentile. Expected: approx_percentile(bigint, double) , approx_percentile(bigint, bigint, double) , approx_percentile(bigint, bigint, double, double) , approx_percentile(bigint, array(double)) , approx_percentile(bigint, bigint, array(double)) , approx_percentile(double, double) , approx_percentile(double, bigint, double, double) , approx_percentile(double, bigint, double) , approx_percentile(double, array(double)) , approx_percentile(double, bigint, array(double)) , approx_percentile(real, double) , approx_percentile(real, bigint, double, double) , approx_percentile(real, bigint, double) , approx_percentile(real, array(double)) , approx_percentile(real, bigint, array(double))
我理解我的错误,但我找不到一种方法来解决AWS雅典娜/普雷斯托德。即使这样做也有可能吗?我找到了解决方法,并在这里分享:
WITH validValues AS
(SELECT approx_percentile(sessionnumber, ARRAY[0.25,0.50,0.75,0.95, 0.99]) as percentiles from (SELECT sessionnumber from "20180407" where sessionnumber >= 1))
SELECT percentiles FROM testfun, validValues