You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: datafusion/sqllogictest/test_files/lambda.slt
+16-14Lines changed: 16 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ SELECT array_transform([[1, 2]], a -> array_transform(a, a -> a+1))
62
62
query ?
63
63
SELECT array_transform([[[1], [2], [3]]], a -> array_transform(a, b -> array_transform(b, c -> c*2)));
64
64
----
65
-
[[[4], [6], [8]]]
65
+
[[[2], [4], [6]]]
66
66
67
67
# parameter shadows unqualified column
68
68
query I?
@@ -74,20 +74,20 @@ SELECT number, array_transform([1, 2], number -> number+1) from t;
74
74
75
75
# type coercion inside lambda body
76
76
query ?
77
-
SELECT array_transform([1.0, 2.0], v -> v + 3) from t;
77
+
SELECT array_transform([t.number], v -> v + 3.0) from t;
78
78
----
79
-
[11.0, 12.0]
80
-
[41.0, 42.0]
81
-
[61.0, 62.0]
79
+
[13.0]
80
+
[43.0]
81
+
[63.0]
82
82
83
83
query TT
84
-
EXPLAIN SELECT array_transform([1.0, 2.0], v -> v + 3) from t;
84
+
EXPLAIN SELECT array_transform([t.number], v -> v + 3.0) from t;
85
85
----
86
86
logical_plan
87
-
01)Projection: array_transform(List([1.0, 2.0]), (v) -> v + CAST(t.number AS Float64)) AS array_transform(make_array(Float64(1),Float64(2)),(v) -> v + t.number)
87
+
01)Projection: array_transform(make_array(t.number), (v) -> CAST(v AS Float64) + Float64(3))
88
88
02)--TableScan: t projection=[number]
89
89
physical_plan
90
-
01)ProjectionExec: expr=[array_transform([1.0, 2.0], (v) -> v@ + CAST(number@0 AS Float64)) as array_transform(make_array(Float64(1),Float64(2)),(v) -> v + t.number)]
90
+
01)ProjectionExec: expr=[array_transform(make_array(number@0), (v) -> CAST(v@ AS Float64) + 3) as array_transform(make_array(t.number),(v) -> v + Float64(3))]
# test that sql planner plans resolved lambda variables, as v[1] planning checks the datatype of lhs
@@ -163,7 +165,7 @@ select array_transform(1, v -> v*2);
163
165
query error DataFusion error: Error during planning: array_transform expects a value followed by a lambda, got Lambda\(\(\)\) and Value\(Field \{ name: "make_array\(Int64\(1\),Int64\(2\)\)", data_type: List\(Field \{ data_type: Int64, nullable: true \}\), nullable: true \}\)
164
166
select array_transform(v -> v*2, [1, 2]);
165
167
166
-
query error DataFusion error: Error during planning: lambda defined 3 params but UDF support only 2
168
+
query error DataFusion error: Error during planning: lambda defined 3 params but UDF support only 1
167
169
SELECT array_transform([1, 2], (e, i, j) -> i);
168
170
169
171
query error DataFusion error: Error during planning: lambda parameters names must be unique, got \(v, v\)
0 commit comments