Skip to content

Commit 535c513

Browse files
committed
cleaning up
1 parent d950cd0 commit 535c513

File tree

6 files changed

+133
-40
lines changed

6 files changed

+133
-40
lines changed

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/rules/AggregateDataAccessRule.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import com.apple.foundationdb.record.query.plan.cascades.RequestedOrderingConstraint;
4040
import com.apple.foundationdb.record.query.plan.cascades.ValueEquivalence;
4141
import com.apple.foundationdb.record.query.plan.cascades.expressions.RelationalExpression;
42-
import com.apple.foundationdb.record.query.plan.cascades.expressions.SelectExpression;
4342
import com.apple.foundationdb.record.query.plan.cascades.matching.structure.BindingMatcher;
4443
import com.apple.foundationdb.record.query.plan.cascades.typing.Type;
4544
import com.apple.foundationdb.record.query.plan.cascades.values.QuantifiedObjectValue;
@@ -76,12 +75,8 @@
7675
import static com.apple.foundationdb.record.query.plan.cascades.matching.structure.RelationalExpressionMatchers.anyExpression;
7776

7877
/**
79-
* A rule that utilizes index matching information compiled by {@link CascadesPlanner} to create one or more
80-
* expressions for data access specifically for a {@link SelectExpression}. A {@link SelectExpression} behaves
81-
* different compared to essentially all other expressions in a way that we can conceptually deconstruct such an expression
82-
* on the fly and only replace the matched part of the original expression with the scan over the materialized view.
83-
* That allows us to relax restrictions (.e.g. to match all quantifiers the select expression owns) while matching
84-
* select expressions.
78+
* A rule that utilizes index matching information compiled by {@link CascadesPlanner} to create a multitude of
79+
* expressions for data access involving {@link AggregateIndexMatchCandidate}.
8580
*/
8681
@API(API.Status.EXPERIMENTAL)
8782
@SuppressWarnings("PMD.TooManyStaticImports")

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/rules/WithPrimaryKeyDataAccessRule.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public void onMatch(@Nonnull final CascadesRuleCall call) {
9898
}
9999

100100
final var expression = bindings.get(getExpressionMatcher());
101-
final var correlatedTo = expression.getCorrelatedTo();
102101

103102
//
104103
// return if there is no pre-determined interesting ordering

yaml-tests/src/test/java/YamlIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public void enumTest(YamlTest.Runner runner) throws Exception {
255255
}
256256

257257
@TestTemplate
258-
@MaintainYamlTestConfig(YamlTestConfigFilters.CORRECT_EXPLAIN_AND_METRICS)
258+
//@MaintainYamlTestConfig(YamlTestConfigFilters.CORRECT_EXPLAIN_AND_METRICS)
259259
public void compositeAggregates(YamlTest.Runner runner) throws Exception {
260260
runner.runYamsql("composite-aggregates.yamsql");
261261
}
Binary file not shown.
Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,113 @@
11
agg-empty-table-tests:
2+
- query: EXPLAIN select sum(col2) / count(col2) from T2 group by col1;
3+
explain: 'AISCAN(T2_I6 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T2_I4
4+
<,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1
5+
RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | MAP (_._1 / _._2 AS _0)'
6+
task_count: 317
7+
task_total_time_ms: 95
8+
transform_count: 115
9+
transform_time_ms: 81
10+
transform_yield_count: 51
11+
insert_time_ms: 0
12+
insert_new_count: 16
13+
insert_reused_count: 0
14+
- query: EXPLAIN select sum(col2), count(col2) from T2 where col1 < 2 group by col1;
15+
explain: 'AISCAN(T2_I6 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP -> [_0: KEY:[0],
16+
_1: VALUE:[0]]) ∩ AISCAN(T2_I4 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP
17+
-> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0
18+
AS _0, q0._1 AS _1, q1._1 AS _2) | MAP (_._1 AS _0, _._2 AS _1)'
19+
task_count: 317
20+
task_total_time_ms: 32
21+
transform_count: 115
22+
transform_time_ms: 27
23+
transform_yield_count: 51
24+
insert_time_ms: 0
25+
insert_new_count: 16
26+
insert_reused_count: 0
27+
- query: EXPLAIN select sum(col2), count(col2) from T2 group by col1 having sum(col2)
28+
= 17;
29+
explain: 'AISCAN(T2_I6 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T2_I4
30+
<,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1
31+
RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | FILTER _._1 EQUALS promote(@c22
32+
AS LONG) | MAP (_._1 AS _0, _._2 AS _1)'
33+
task_count: 349
34+
task_total_time_ms: 27
35+
transform_count: 120
36+
transform_time_ms: 19
37+
transform_yield_count: 52
38+
insert_time_ms: 1
39+
insert_new_count: 20
40+
insert_reused_count: 0
41+
- query: EXPLAIN select sum(col2), count(col2) from T2 where col1 < 2 group by col1
42+
having sum(col2) = 17;
43+
explain: 'AISCAN(T2_I6 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP -> [_0: KEY:[0],
44+
_1: VALUE:[0]]) ∩ AISCAN(T2_I4 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP
45+
-> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0
46+
AS _0, q0._1 AS _1, q1._1 AS _2) | FILTER _._1 EQUALS promote(@c26 AS LONG)
47+
| MAP (_._1 AS _0, _._2 AS _1)'
48+
task_count: 349
49+
task_total_time_ms: 17
50+
transform_count: 120
51+
transform_time_ms: 13
52+
transform_yield_count: 52
53+
insert_time_ms: 0
54+
insert_new_count: 20
55+
insert_reused_count: 0
56+
- query: EXPLAIN select sum(col1) / count(col1), col2 from T1 group by col2;
57+
explain: 'AISCAN(T1_I2 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T1_I1
58+
<,> BY_GROUP -> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) | AGG sum_l(_._2)
59+
GROUP BY (_._0 AS _0) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1
60+
AS _1, q1._1 AS _2) | MAP (_._1 / _._2 AS _0, _._0 AS COL2)'
61+
task_count: 475
62+
task_total_time_ms: 26
63+
transform_count: 143
64+
transform_time_ms: 17
65+
transform_yield_count: 49
66+
insert_time_ms: 0
67+
insert_new_count: 36
68+
insert_reused_count: 0
69+
- query: EXPLAIN select col2, sum(col1) / count(col1) from T1 where col2 < 2 group
70+
by col2 having sum(col1) = 17 order by col2;
71+
explain: 'AISCAN(T1_I2 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP -> [_0: KEY:[0],
72+
_1: VALUE:[0]]) ∩ AISCAN(T1_I1 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP
73+
-> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) | AGG sum_l(_._2) GROUP BY (_._0
74+
AS _0) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1
75+
AS _2) | FILTER _._1 EQUALS promote(@c28 AS LONG) | MAP (_._0 AS COL2, _._1
76+
/ _._2 AS _1)'
77+
task_count: 528
78+
task_total_time_ms: 23
79+
transform_count: 152
80+
transform_time_ms: 18
81+
transform_yield_count: 51
82+
insert_time_ms: 0
83+
insert_new_count: 43
84+
insert_reused_count: 0
85+
- query: EXPLAIN select col2, sum(col1) / count(col1) from T1 where col2 < 2 group
86+
by col2, col3 having sum(col1) = 17;
87+
explain: 'AISCAN(T1_I4 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP -> [_0: KEY:[0],
88+
_1: KEY:[1], _2: VALUE:[0]]) ∩ AISCAN(T1_I1 [[LESS_THAN promote(@c18 AS LONG)]]
89+
BY_GROUP -> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) COMPARE BY (_._0, _._1)
90+
WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q0._2 AS _2, q1._2 AS _3) |
91+
FILTER _._2 EQUALS promote(@c30 AS LONG) | MAP (_._0 AS COL2, _._2 / _._3
92+
AS _1)'
93+
task_count: 335
94+
task_total_time_ms: 26
95+
transform_count: 111
96+
transform_time_ms: 22
97+
transform_yield_count: 45
98+
insert_time_ms: 0
99+
insert_new_count: 20
100+
insert_reused_count: 0
2101
- query: EXPLAIN select col1, min(col2), max(col2) from T3 group by col1, col3;
3102
explain: 'AISCAN(T3_I2 <,> BY_GROUP -> [_0: KEY:[0], _1: KEY:[2], _2: KEY:[1]])
4103
∩ AISCAN(T3_I1 <,> BY_GROUP -> [_0: KEY:[0], _1: KEY:[2], _2: KEY:[1]]) COMPARE
5104
BY (_._0, _._2, _._1) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q0._2
6105
AS _2, q1._2 AS _3) | MAP (_._0 AS COL1, _._2 AS _1, _._3 AS _2)'
7106
task_count: 468
8-
task_total_time_ms: 118
107+
task_total_time_ms: 27
9108
transform_count: 154
10-
transform_time_ms: 96
109+
transform_time_ms: 19
11110
transform_yield_count: 55
12-
insert_time_ms: 3
111+
insert_time_ms: 2
13112
insert_new_count: 54
14113
insert_reused_count: 4

yaml-tests/src/test/resources/composite-aggregates.yamsql

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,34 +69,34 @@ test_block:
6969
name: agg-empty-table-tests
7070
preset: single_repetition_ordered
7171
tests:
72-
#-
73-
# - query: select sum(col2) / count(col2) from T2 group by col1;
74-
# - explain: "AISCAN(T2_I6 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T2_I4 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | MAP (_._1 / _._2 AS _0)"
75-
# - result: [{!l 4}, {!l 32}]
76-
#-
77-
# - query: select sum(col2), count(col2) from T2 where col1 < 2 group by col1;
78-
# - explain: "AISCAN(T2_I6 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T2_I4 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | MAP (_._1 AS _0, _._2 AS _1)"
79-
# - result: [{!l 17, !l 4}]
80-
#-
81-
# - query: select sum(col2), count(col2) from T2 group by col1 having sum(col2) = 17;
82-
# - explain: "AISCAN(T2_I6 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T2_I4 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | FILTER _._1 EQUALS promote(@c22 AS LONG) | MAP (_._1 AS _0, _._2 AS _1)"
83-
# - result: [{!l 17, !l 4}]
84-
#-
85-
# - query: select sum(col2), count(col2) from T2 where col1 < 2 group by col1 having sum(col2) = 17;
86-
# - explain: "AISCAN(T2_I6 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T2_I4 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | FILTER _._1 EQUALS promote(@c26 AS LONG) | MAP (_._1 AS _0, _._2 AS _1)"
87-
# - result: [{!l 17, !l 4}]
88-
#-
89-
# - query: select sum(col1) / count(col1), col2 from T1 group by col2;
90-
# - explain: "AISCAN(T1_I2 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T1_I1 <,> BY_GROUP -> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) | AGG sum_l(_._2) GROUP BY (_._0 AS _0) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | MAP (_._1 / _._2 AS _0, _._0 AS COL2)"
91-
# - result: [{!l 10, !l 1}, {!l 20, !l 6}, {!l 20, !l 7}, {!l 20, !l 8}, {!l 20, !l 10}]
92-
#-
93-
# - query: select col2, sum(col1) / count(col1) from T1 where col2 < 2 group by col2 having sum(col1) = 17 order by col2;
94-
# - explain: "AISCAN(T1_I2 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T1_I1 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) | AGG sum_l(_._2) GROUP BY (_._0 AS _0) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | FILTER _._1 EQUALS promote(@c28 AS LONG) | MAP (_._0 AS COL2, _._1 / _._2 AS _1)"
95-
# - result: []
96-
#-
97-
# - query: select col2, sum(col1) / count(col1) from T1 where col2 < 2 group by col2, col3 having sum(col1) = 17;
98-
# - explain: "AISCAN(T1_I4 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) ∩ AISCAN(T1_I1 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) COMPARE BY (_._0, _._1) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q0._2 AS _2, q1._2 AS _3) | FILTER _._2 EQUALS promote(@c30 AS LONG) | MAP (_._0 AS COL2, _._2 / _._3 AS _1)"
99-
# - result: []
72+
-
73+
- query: select sum(col2) / count(col2) from T2 group by col1;
74+
- explain: "AISCAN(T2_I6 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T2_I4 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | MAP (_._1 / _._2 AS _0)"
75+
- result: [{!l 4}, {!l 32}]
76+
-
77+
- query: select sum(col2), count(col2) from T2 where col1 < 2 group by col1;
78+
- explain: "AISCAN(T2_I6 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T2_I4 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | MAP (_._1 AS _0, _._2 AS _1)"
79+
- result: [{!l 17, !l 4}]
80+
-
81+
- query: select sum(col2), count(col2) from T2 group by col1 having sum(col2) = 17;
82+
- explain: "AISCAN(T2_I6 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T2_I4 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | FILTER _._1 EQUALS promote(@c22 AS LONG) | MAP (_._1 AS _0, _._2 AS _1)"
83+
- result: [{!l 17, !l 4}]
84+
-
85+
- query: select sum(col2), count(col2) from T2 where col1 < 2 group by col1 having sum(col2) = 17;
86+
- explain: "AISCAN(T2_I6 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T2_I4 [[LESS_THAN promote(@c16 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | FILTER _._1 EQUALS promote(@c26 AS LONG) | MAP (_._1 AS _0, _._2 AS _1)"
87+
- result: [{!l 17, !l 4}]
88+
-
89+
- query: select sum(col1) / count(col1), col2 from T1 group by col2;
90+
- explain: "AISCAN(T1_I2 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T1_I1 <,> BY_GROUP -> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) | AGG sum_l(_._2) GROUP BY (_._0 AS _0) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | MAP (_._1 / _._2 AS _0, _._0 AS COL2)"
91+
- result: [{!l 10, !l 1}, {!l 20, !l 6}, {!l 20, !l 7}, {!l 20, !l 8}, {!l 20, !l 10}]
92+
-
93+
- query: select col2, sum(col1) / count(col1) from T1 where col2 < 2 group by col2 having sum(col1) = 17 order by col2;
94+
- explain: "AISCAN(T1_I2 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) ∩ AISCAN(T1_I1 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) | AGG sum_l(_._2) GROUP BY (_._0 AS _0) COMPARE BY (_._0) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q1._1 AS _2) | FILTER _._1 EQUALS promote(@c28 AS LONG) | MAP (_._0 AS COL2, _._1 / _._2 AS _1)"
95+
- result: []
96+
-
97+
- query: select col2, sum(col1) / count(col1) from T1 where col2 < 2 group by col2, col3 having sum(col1) = 17;
98+
- explain: "AISCAN(T1_I4 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) ∩ AISCAN(T1_I1 [[LESS_THAN promote(@c18 AS LONG)]] BY_GROUP -> [_0: KEY:[0], _1: KEY:[1], _2: VALUE:[0]]) COMPARE BY (_._0, _._1) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q0._2 AS _2, q1._2 AS _3) | FILTER _._2 EQUALS promote(@c30 AS LONG) | MAP (_._0 AS COL2, _._2 / _._3 AS _1)"
99+
- result: []
100100
-
101101
- query: select col1, min(col2), max(col2) from T3 group by col1, col3;
102102
- explain: "AISCAN(T3_I2 <,> BY_GROUP -> [_0: KEY:[0], _1: KEY:[2], _2: KEY:[1]]) ∩ AISCAN(T3_I1 <,> BY_GROUP -> [_0: KEY:[0], _1: KEY:[2], _2: KEY:[1]]) COMPARE BY (_._0, _._2, _._1) WITH q0, q1 RETURN (q0._0 AS _0, q0._1 AS _1, q0._2 AS _2, q1._2 AS _3) | MAP (_._0 AS COL1, _._2 AS _1, _._3 AS _2)"

0 commit comments

Comments
 (0)