Details
-
Bug
-
Resolution: Fixed
-
Major
-
7.2.0
-
Untriaged
-
1
-
Unknown
Description
Issue | Resolution |
When a WITH clause (common table expression, or CTE) was used inside a subquery, and the WITH clause definition referenced the parent query, and was correlated, the query engine did not properly detect the correlation. This produced an incorrect result from the WITH clause evaluation because the result was not cached correctly. | Correlations inside WITH clause definitions are now properly detected. |
Repro:
insert into default values(UUID(), {"arr": [1,2,3], "c2":5});
|
insert into default values(UUID(), {"arr": [11,12,13], "c2":5});
|
|
create primary index on default;
|
|
SELECT ( WITH a AS (d.arr) SELECT raw c1 FROM a AS c1) AS arr FROM default d WHERE d.c2 = 5;
|
"results": [
|
{
|
"arr": [
|
11,
|
12,
|
13
|
]
|
},
|
{
|
"arr": [
|
11,
|
12,
|
13
|
]
|
}
|
],
|
|
Similar LET clause works as expected:
SELECT ( SELECT raw b FROM 1 AS c1 LET b = d.arr) AS arr FROM default d WHERE d.c2 = 5;
|
"results": [
|
{
|
"arr": [
|
[
|
11,
|
12,
|
13
|
]
|
]
|
},
|
{
|
"arr": [
|
[
|
1,
|
2,
|
3
|
]
|
]
|
}
|
],
|
|
Similar query with subquery as the binding expression of WITH clause:
SELECT ( WITH a AS ((SELECT RAW d.arr)[0]) SELECT raw c1 FROM a AS c1) AS arr FROM default d WHERE d.c2 = 5;
|