World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
-- Automatically generated by Gravitino Spark SQL test
-- !query
CREATE OR REPLACE TEMPORARY VIEW testData AS SELECT * FROM VALUES
(1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2), (null, 1), (3, null), (null, null)
AS testData(a, b)
-- !query schema
struct<>
-- !query output
-- !query
CREATE OR REPLACE TEMPORARY VIEW testRegression AS SELECT * FROM VALUES
(1, 10, null), (2, 10, 11), (2, 20, 22), (2, 25, null), (2, 30, 35)
AS testRegression(k, y, x)
-- !query schema
struct<>
-- !query output
-- !query
CREATE OR REPLACE TEMPORARY VIEW aggr AS SELECT * FROM VALUES
(0, 0), (0, 10), (0, 20), (0, 30), (0, 40), (1, 10), (1, 20), (2, 10), (2, 20), (2, 25), (2, 30), (3, 60), (4, null)
AS aggr(k, v)
-- !query schema
struct<>
-- !query output
-- !query
SELECT a, COUNT(b) FROM testData
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT COUNT(a), COUNT(b) FROM testData
-- !query schema
struct<count(a):bigint,count(b):bigint>
-- !query output
7 7
-- !query
SELECT a, COUNT(b) FROM testData GROUP BY a
-- !query schema
struct<a:int,count(b):bigint>
-- !query output
1 2
2 2
3 2
NULL 1
-- !query
SELECT a, COUNT(b) FROM testData GROUP BY b
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT COUNT(a), COUNT(b) FROM testData GROUP BY a
-- !query schema
struct<count(a):bigint,count(b):bigint>
-- !query output
0 1
2 2
2 2
3 2
-- !query
SELECT 'foo', COUNT(a) FROM testData GROUP BY 1
-- !query schema
struct<foo:string,count(a):bigint>
-- !query output
foo 7
-- !query
SELECT 'foo' FROM testData WHERE a = 0 GROUP BY 1
-- !query schema
struct<foo:string>
-- !query output
-- !query
SELECT 'foo', APPROX_COUNT_DISTINCT(a) FROM testData WHERE a = 0 GROUP BY 1
-- !query schema
struct<foo:string,approx_count_distinct(a):bigint>
-- !query output
-- !query
SELECT 'foo', MAX(STRUCT(a)) FROM testData WHERE a = 0 GROUP BY 1
-- !query schema
struct<foo:string,max(struct(a)):struct<a:int>>
-- !query output
-- !query
SELECT a + b, COUNT(b) FROM testData GROUP BY a + b
-- !query schema
struct<(a + b):int,count(b):bigint>
-- !query output
2 1
3 2
4 2
5 1
NULL 1
-- !query
SELECT a + 2, COUNT(b) FROM testData GROUP BY a + 1
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT a + 1 + 1, COUNT(b) FROM testData GROUP BY a + 1
-- !query schema
struct<((a + 1) + 1):int,count(b):bigint>
-- !query output
3 2
4 2
5 2
NULL 1
-- !query
SELECT SKEWNESS(a), KURTOSIS(a), MIN(a), MAX(a), AVG(a), VARIANCE(a), STDDEV(a), SUM(a), COUNT(a)
FROM testData
-- !query schema
struct<skewness(a):double,kurtosis(a):double,min(a):int,max(a):int,avg(a):double,variance(a):double,stddev(a):double,sum(a):bigint,count(a):bigint>
-- !query output
-0.27238010581457267 -1.506920415224914 1 3 2.142857142857143 0.8095238095238096 0.8997354108424375 15 7
-- !query
SELECT COUNT(DISTINCT b), COUNT(DISTINCT b, c) FROM (SELECT 1 AS a, 2 AS b, 3 AS c) GROUP BY a
-- !query schema
struct<count(DISTINCT b):bigint,count(DISTINCT b, c):bigint>
-- !query output
1 1
-- !query
SELECT a AS k, COUNT(b) FROM testData GROUP BY k
-- !query schema
struct<k:int,count(b):bigint>
-- !query output
1 2
2 2
3 2
NULL 1
-- !query
SELECT a AS k, COUNT(b) FROM testData GROUP BY k HAVING k > 1
-- !query schema
struct<k:int,count(b):bigint>
-- !query output
2 2
3 2
-- !query
SELECT a AS k, COUNT(non_existing) FROM testData GROUP BY k
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT COUNT(b) AS k FROM testData GROUP BY k
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
CREATE OR REPLACE TEMPORARY VIEW testDataHasSameNameWithAlias AS SELECT * FROM VALUES
(1, 1, 3), (1, 2, 1) AS testDataHasSameNameWithAlias(k, a, v)
-- !query schema
struct<>
-- !query output
-- !query
SELECT k AS a, COUNT(v) FROM testDataHasSameNameWithAlias GROUP BY a
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
set spark.sql.groupByAliases=false
-- !query schema
struct<key:string,value:string>
-- !query output
spark.sql.groupByAliases false
-- !query
SELECT a AS k, COUNT(b) FROM testData GROUP BY k
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT a, COUNT(1) FROM testData WHERE false GROUP BY a
-- !query schema
struct<a:int,count(1):bigint>
-- !query output
-- !query
SELECT COUNT(1) FROM testData WHERE false
-- !query schema
struct<count(1):bigint>
-- !query output
0
-- !query
SELECT 1 FROM (SELECT COUNT(1) FROM testData WHERE false) t
-- !query schema
struct<1:int>
-- !query output
1
-- !query
SELECT 1 from (
SELECT 1 AS z,
MIN(a.x)
FROM (select 1 as x) a
WHERE false
) b
where b.z != b.z
-- !query schema
struct<1:int>
-- !query output
-- !query
SELECT corr(DISTINCT x, y), corr(DISTINCT y, x), count(*)
FROM (VALUES (1, 1), (2, 2), (2, 2)) t(x, y)
-- !query schema
struct<corr(DISTINCT x, y):double,corr(DISTINCT y, x):double,count(1):bigint>
-- !query output
1.0 1.0 3
-- !query
SELECT 1 FROM range(10) HAVING true
-- !query schema
struct<1:int>
-- !query output
1
-- !query
SELECT 1 FROM range(10) HAVING MAX(id) > 0
-- !query schema
struct<1:int>
-- !query output
1
-- !query
SELECT id FROM range(10) HAVING id > 0
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SET spark.sql.legacy.parser.havingWithoutGroupByAsWhere=true
-- !query schema
struct<key:string,value:string>
-- !query output
spark.sql.legacy.parser.havingWithoutGroupByAsWhere true
-- !query
SELECT 1 FROM range(10) HAVING true
-- !query schema
struct<1:int>
-- !query output
1
1
1
1
1
1
1
1
1
1
-- !query
SELECT 1 FROM range(10) HAVING MAX(id) > 0
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT id FROM range(10) HAVING id > 0
-- !query schema
struct<id:bigint>
-- !query output
1
2
3
4
5
6
7
8
9
-- !query
SET spark.sql.legacy.parser.havingWithoutGroupByAsWhere=false
-- !query schema
struct<key:string,value:string>
-- !query output
spark.sql.legacy.parser.havingWithoutGroupByAsWhere false
-- !query
CREATE OR REPLACE TEMPORARY VIEW test_agg AS SELECT * FROM VALUES
(1, true), (1, false),
(2, true),
(3, false), (3, null),
(4, null), (4, null),
(5, null), (5, true), (5, false) AS test_agg(k, v)
-- !query schema
struct<>
-- !query output
-- !query
SELECT every(v), some(v), any(v), bool_and(v), bool_or(v) FROM test_agg WHERE 1 = 0
-- !query schema
struct<every(v):boolean,some(v):boolean,any(v):boolean,bool_and(v):boolean,bool_or(v):boolean>
-- !query output
NULL NULL NULL NULL NULL
-- !query
SELECT every(v), some(v), any(v), bool_and(v), bool_or(v) FROM test_agg WHERE k = 4
-- !query schema
struct<every(v):boolean,some(v):boolean,any(v):boolean,bool_and(v):boolean,bool_or(v):boolean>
-- !query output
NULL NULL NULL NULL NULL
-- !query
SELECT every(v), some(v), any(v), bool_and(v), bool_or(v) FROM test_agg WHERE k = 5
-- !query schema
struct<every(v):boolean,some(v):boolean,any(v):boolean,bool_and(v):boolean,bool_or(v):boolean>
-- !query output
false true true false true
-- !query
SELECT k, every(v), some(v), any(v), bool_and(v), bool_or(v) FROM test_agg GROUP BY k
-- !query schema
struct<k:int,every(v):boolean,some(v):boolean,any(v):boolean,bool_and(v):boolean,bool_or(v):boolean>
-- !query output
1 false true true false true
2 true true true true true
3 false false false false false
4 NULL NULL NULL NULL NULL
5 false true true false true
-- !query
SELECT k, every(v) FROM test_agg GROUP BY k HAVING every(v) = false
-- !query schema
struct<k:int,every(v):boolean>
-- !query output
1 false
3 false
5 false
-- !query
SELECT k, every(v) FROM test_agg GROUP BY k HAVING every(v) IS NULL
-- !query schema
struct<k:int,every(v):boolean>
-- !query output
4 NULL
-- !query
SELECT k,
Every(v) AS every
FROM test_agg
WHERE k = 2
AND v IN (SELECT Any(v)
FROM test_agg
WHERE k = 1)
GROUP BY k
-- !query schema
struct<k:int,every:boolean>
-- !query output
2 true
-- !query
SELECT k,
Every(v) AS every
FROM test_agg
WHERE k = 2
AND v IN (SELECT Every(v)
FROM test_agg
WHERE k = 1)
GROUP BY k
-- !query schema
struct<k:int,every:boolean>
-- !query output
-- !query
SELECT every(1)
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT some(1S)
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT any(1L)
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT every("true")
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT bool_and(1.0)
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT bool_or(1.0D)
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT k, v, every(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
-- !query schema
struct<k:int,v:boolean,every(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
-- !query output
1 false false
1 true false
2 true true
3 NULL NULL
3 false false
4 NULL NULL
4 NULL NULL
5 NULL NULL
5 false false
5 true false
-- !query
SELECT k, v, some(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
-- !query schema
struct<k:int,v:boolean,some(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
-- !query output
1 false false
1 true true
2 true true
3 NULL NULL
3 false false
4 NULL NULL
4 NULL NULL
5 NULL NULL
5 false false
5 true true
-- !query
SELECT k, v, any(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
-- !query schema
struct<k:int,v:boolean,any(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
-- !query output
1 false false
1 true true
2 true true
3 NULL NULL
3 false false
4 NULL NULL
4 NULL NULL
5 NULL NULL
5 false false
5 true true
-- !query
SELECT k, v, bool_and(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
-- !query schema
struct<k:int,v:boolean,bool_and(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
-- !query output
1 false false
1 true false
2 true true
3 NULL NULL
3 false false
4 NULL NULL
4 NULL NULL
5 NULL NULL
5 false false
5 true false
-- !query
SELECT k, v, bool_or(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
-- !query schema
struct<k:int,v:boolean,bool_or(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
-- !query output
1 false false
1 true true
2 true true
3 NULL NULL
3 false false
4 NULL NULL
4 NULL NULL
5 NULL NULL
5 false false
5 true true
-- !query
SELECT count(*) FROM test_agg HAVING count(*) > 1L
-- !query schema
struct<count(1):bigint>
-- !query output
10
-- !query
SELECT k, max(v) FROM test_agg GROUP BY k HAVING max(v) = true
-- !query schema
struct<k:int,max(v):boolean>
-- !query output
1 true
2 true
5 true
-- !query
SELECT * FROM (SELECT COUNT(*) AS cnt FROM test_agg) WHERE cnt > 1L
-- !query schema
struct<cnt:bigint>
-- !query output
10
-- !query
SELECT count(*) FROM test_agg WHERE count(*) > 1L
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT count(*) FROM test_agg WHERE count(*) + 1L > 1L
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT count(*) FROM test_agg WHERE k = 1 or k = 2 or count(*) + 1L > 1L or max(k) > 1
-- !query schema
struct<>
-- !query output
[SPARK_EXCEPTION]
-- !query
SELECT AVG(DISTINCT decimal_col), SUM(DISTINCT decimal_col) FROM VALUES (CAST(1 AS DECIMAL(9, 0))) t(decimal_col)
-- !query schema
struct<avg(DISTINCT decimal_col):decimal(13,4),sum(DISTINCT decimal_col):decimal(19,0)>
-- !query output
1.0000 1
-- !query
SELECT not(a IS NULL), count(*) AS c
FROM testData
GROUP BY a IS NULL
-- !query schema
struct<(NOT (a IS NULL)):boolean,c:bigint>
-- !query output
false 2
true 7
-- !query
SELECT if(not(a IS NULL), rand(0), 1), count(*) AS c
FROM testData
GROUP BY a IS NULL
-- !query schema
struct<(IF((NOT (a IS NULL)), rand(0), 1)):double,c:bigint>
-- !query output
0.7604953758285915 7
1.0 2
-- !query
SELECT
histogram_numeric(col, 2) as histogram_2,
histogram_numeric(col, 3) as histogram_3,
histogram_numeric(col, 5) as histogram_5,
histogram_numeric(col, 10) as histogram_10
FROM VALUES
(1), (2), (3), (4), (5), (6), (7), (8), (9), (10),
(11), (12), (13), (14), (15), (16), (17), (18), (19), (20),
(21), (22), (23), (24), (25), (26), (27), (28), (29), (30),
(31), (32), (33), (34), (35), (3), (37), (38), (39), (40),
(41), (42), (43), (44), (45), (46), (47), (48), (49), (50) AS tab(col)
-- !query schema
struct<histogram_2:array<struct<x:int,y:double>>,histogram_3:array<struct<x:int,y:double>>,histogram_5:array<struct<x:int,y:double>>,histogram_10:array<struct<x:int,y:double>>>
-- !query output
[{"x":17,"y":36.0},{"x":43,"y":14.0}] [{"x":9,"y":20.0},{"x":28,"y":17.0},{"x":44,"y":13.0}] [{"x":5,"y":11.0},{"x":14,"y":8.0},{"x":22,"y":7.0},{"x":30,"y":10.0},{"x":43,"y":14.0}] [{"x":3,"y":6.0},{"x":8,"y":6.0},{"x":14,"y":7.0},{"x":20,"y":4.0},{"x":24,"y":3.0},{"x":27,"y":4.0},{"x":31,"y":4.0},{"x":36,"y":4.0},{"x":42,"y":7.0},{"x":48,"y":5.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES (1), (2), (3) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:int,y:double>>>
-- !query output
[{"x":1,"y":1.0},{"x":2,"y":1.0},{"x":3,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES (1L), (2L), (3L) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:bigint,y:double>>>
-- !query output
[{"x":1,"y":1.0},{"x":2,"y":1.0},{"x":3,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES (1F), (2F), (3F) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:float,y:double>>>
-- !query output
[{"x":1.0,"y":1.0},{"x":2.0,"y":1.0},{"x":3.0,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES (1D), (2D), (3D) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:double,y:double>>>
-- !query output
[{"x":1.0,"y":1.0},{"x":2.0,"y":1.0},{"x":3.0,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES (1S), (2S), (3S) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:smallint,y:double>>>
-- !query output
[{"x":1,"y":1.0},{"x":2,"y":1.0},{"x":3,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES
(CAST(1 AS BYTE)), (CAST(2 AS BYTE)), (CAST(3 AS BYTE)) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:tinyint,y:double>>>
-- !query output
[{"x":1,"y":1.0},{"x":2,"y":1.0},{"x":3,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES
(CAST(1 AS TINYINT)), (CAST(2 AS TINYINT)), (CAST(3 AS TINYINT)) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:tinyint,y:double>>>
-- !query output
[{"x":1,"y":1.0},{"x":2,"y":1.0},{"x":3,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES
(CAST(1 AS SMALLINT)), (CAST(2 AS SMALLINT)), (CAST(3 AS SMALLINT)) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:smallint,y:double>>>
-- !query output
[{"x":1,"y":1.0},{"x":2,"y":1.0},{"x":3,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES
(CAST(1 AS BIGINT)), (CAST(2 AS BIGINT)), (CAST(3 AS BIGINT)) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:bigint,y:double>>>
-- !query output
[{"x":1,"y":1.0},{"x":2,"y":1.0},{"x":3,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES (TIMESTAMP '2017-03-01 00:00:00'),
(TIMESTAMP '2017-04-01 00:00:00'), (TIMESTAMP '2017-05-01 00:00:00') AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:timestamp,y:double>>>
-- !query output
[{"x":2017-03-01 00:00:00,"y":1.0},{"x":2017-04-01 00:00:00,"y":1.0},{"x":2017-05-01 00:00:00,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES (INTERVAL '100-00' YEAR TO MONTH),
(INTERVAL '110-00' YEAR TO MONTH), (INTERVAL '120-00' YEAR TO MONTH) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:interval year to month,y:double>>>
-- !query output
[{"x":100-0,"y":1.0},{"x":110-0,"y":1.0},{"x":120-0,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3) FROM VALUES (INTERVAL '12 20:4:0' DAY TO SECOND),
(INTERVAL '12 21:4:0' DAY TO SECOND), (INTERVAL '12 22:4:0' DAY TO SECOND) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:interval day to second,y:double>>>
-- !query output
[{"x":12 20:04:00.000000000,"y":1.0},{"x":12 21:04:00.000000000,"y":1.0},{"x":12 22:04:00.000000000,"y":1.0}]
-- !query
SELECT histogram_numeric(col, 3)
FROM VALUES (NULL), (NULL), (NULL) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:double,y:double>>>
-- !query output
NULL
-- !query
SELECT histogram_numeric(col, 3)
FROM VALUES (CAST(NULL AS DOUBLE)), (CAST(NULL AS DOUBLE)), (CAST(NULL AS DOUBLE)) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:double,y:double>>>
-- !query output
NULL
-- !query
SELECT histogram_numeric(col, 3)
FROM VALUES (CAST(NULL AS INT)), (CAST(NULL AS INT)), (CAST(NULL AS INT)) AS tab(col)
-- !query schema
struct<histogram_numeric(col, 3):array<struct<x:int,y:double>>>
-- !query output
NULL
-- !query
SELECT regr_count(y, x) FROM testRegression
-- !query schema
struct<regr_count(y, x):bigint>
-- !query output
3
-- !query
SELECT regr_count(y, x) FROM testRegression WHERE x IS NOT NULL
-- !query schema
struct<regr_count(y, x):bigint>
-- !query output
3
-- !query
SELECT k, count(*), regr_count(y, x) FROM testRegression GROUP BY k
-- !query schema
struct<k:int,count(1):bigint,regr_count(y, x):bigint>
-- !query output
1 1 0
2 4 3
-- !query
SELECT k, count(*) FILTER (WHERE x IS NOT NULL), regr_count(y, x) FROM testRegression GROUP BY k
-- !query schema
struct<k:int,count(1) FILTER (WHERE (x IS NOT NULL)):bigint,regr_count(y, x):bigint>
-- !query output
1 0 0
2 3 3
-- !query
SELECT regr_r2(y, x) FROM testRegression
-- !query schema
struct<regr_r2(y, x):double>
-- !query output
0.9976905311778288
-- !query
SELECT regr_r2(y, x) FROM testRegression WHERE x IS NOT NULL
-- !query schema
struct<regr_r2(y, x):double>
-- !query output
0.9976905311778288
-- !query
SELECT k, corr(y, x), regr_r2(y, x) FROM testRegression GROUP BY k
-- !query schema
struct<k:int,corr(y, x):double,regr_r2(y, x):double>
-- !query output
1 NULL NULL
2 0.9988445981121532 0.9976905311778288
-- !query
SELECT k, corr(y, x) FILTER (WHERE x IS NOT NULL), regr_r2(y, x) FROM testRegression GROUP BY k
-- !query schema
struct<k:int,corr(y, x) FILTER (WHERE (x IS NOT NULL)):double,regr_r2(y, x):double>
-- !query output
1 NULL NULL
2 0.9988445981121532 0.9976905311778288
-- !query
SELECT
collect_list(col),
array_agg(col)
FROM VALUES
(1), (2), (1) AS tab(col)
-- !query schema
struct<collect_list(col):array<int>,collect_list(col):array<int>>
-- !query output
[1,2,1] [1,2,1]
-- !query
SELECT
a,
collect_list(b),
array_agg(b)
FROM VALUES
(1,4),(2,3),(1,4),(2,4) AS v(a,b)
GROUP BY a
-- !query schema
struct<a:int,collect_list(b):array<int>,collect_list(b):array<int>>
-- !query output
1 [4,4] [4,4]
2 [3,4] [3,4]
-- !query
SELECT regr_avgx(y, x), regr_avgy(y, x) FROM testRegression
-- !query schema
struct<regr_avgx(y, x):double,regr_avgy(y, x):double>
-- !query output
22.666666666666668 20.0
-- !query
SELECT regr_avgx(y, x), regr_avgy(y, x) FROM testRegression WHERE x IS NOT NULL AND y IS NOT NULL
-- !query schema
struct<regr_avgx(y, x):double,regr_avgy(y, x):double>
-- !query output
22.666666666666668 20.0
-- !query
SELECT k, avg(x), avg(y), regr_avgx(y, x), regr_avgy(y, x) FROM testRegression GROUP BY k
-- !query schema
struct<k:int,avg(x):double,avg(y):double,regr_avgx(y, x):double,regr_avgy(y, x):double>
-- !query output
1 NULL 10.0 NULL NULL
2 22.666666666666668 21.25 22.666666666666668 20.0
-- !query
SELECT k, avg(x) FILTER (WHERE x IS NOT NULL AND y IS NOT NULL), avg(y) FILTER (WHERE x IS NOT NULL AND y IS NOT NULL), regr_avgx(y, x), regr_avgy(y, x) FROM testRegression GROUP BY k
-- !query schema
struct<k:int,avg(x) FILTER (WHERE ((x IS NOT NULL) AND (y IS NOT NULL))):double,avg(y) FILTER (WHERE ((x IS NOT NULL) AND (y IS NOT NULL))):double,regr_avgx(y, x):double,regr_avgy(y, x):double>
-- !query output
1 NULL NULL NULL NULL
2 22.666666666666668 20.0 22.666666666666668 20.0
-- !query
SELECT
percentile_cont(0.25) WITHIN GROUP (ORDER BY v),
percentile_cont(0.25) WITHIN GROUP (ORDER BY v DESC)
FROM aggr
-- !query schema
struct<percentile_cont(0.25) WITHIN GROUP (ORDER BY v):double,percentile_cont(0.25) WITHIN GROUP (ORDER BY v DESC):double>
-- !query output
10.0 30.0
-- !query
SELECT
k,
percentile_cont(0.25) WITHIN GROUP (ORDER BY v),
percentile_cont(0.25) WITHIN GROUP (ORDER BY v DESC)
FROM aggr
GROUP BY k
ORDER BY k
-- !query schema
struct<k:int,percentile_cont(0.25) WITHIN GROUP (ORDER BY v):double,percentile_cont(0.25) WITHIN GROUP (ORDER BY v DESC):double>
-- !query output
0 10.0 30.0
1 12.5 17.5
2 17.5 26.25
3 60.0 60.0
4 NULL NULL
-- !query
SELECT
percentile_disc(0.25) WITHIN GROUP (ORDER BY v),
percentile_disc(0.25) WITHIN GROUP (ORDER BY v DESC)
FROM aggr
-- !query schema
struct<percentile_disc(0.25) WITHIN GROUP (ORDER BY v):double,percentile_disc(0.25) WITHIN GROUP (ORDER BY v DESC):double>
-- !query output
10.0 30.0
-- !query
SELECT
k,
percentile_disc(0.25) WITHIN GROUP (ORDER BY v),
percentile_disc(0.25) WITHIN GROUP (ORDER BY v DESC)
FROM aggr
GROUP BY k
ORDER BY k
-- !query schema
struct<k:int,percentile_disc(0.25) WITHIN GROUP (ORDER BY v):double,percentile_disc(0.25) WITHIN GROUP (ORDER BY v DESC):double>
-- !query output
0 10.0 30.0
1 10.0 20.0
2 10.0 30.0
3 60.0 60.0
4 NULL NULL