Skip to content

Commit a3fa29e

Browse files
authored
planner: add test about memo derive stats. (#58207)
ref #51664
1 parent e62963d commit a3fa29e

File tree

3 files changed

+263
-0
lines changed

3 files changed

+263
-0
lines changed

pkg/planner/core/casetest/cascades/memo_test.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,95 @@ func TestDeriveStats(t *testing.T) {
119119
require.Equal(t, output[i].Str, strs, "case i "+tt)
120120
}
121121
}
122+
123+
func TestGroupNDVCols(t *testing.T) {
124+
store := testkit.CreateMockStore(t)
125+
tk := testkit.NewTestKit(t, store)
126+
tk.MustExec("use test")
127+
tk.MustExec("set tidb_cost_model_version=2")
128+
tk.MustExec("drop table if exists t1, t2")
129+
tk.MustExec("create table t1(a int not null, b int not null, key(a,b))")
130+
tk.MustExec("insert into t1 values(1,1),(1,2),(2,1),(2,2)")
131+
tk.MustExec("create table t2(a int not null, b int not null, key(a,b))")
132+
tk.MustExec("insert into t2 values(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3)")
133+
tk.MustExec("analyze table t1")
134+
tk.MustExec("analyze table t2")
135+
136+
// Default RPC encoding may cause statistics explain result differ and then the test unstable.
137+
tk.MustExec("set @@tidb_enable_chunk_rpc = on")
138+
139+
ctx := context.Background()
140+
p := parser.New()
141+
var input []string
142+
var output []struct {
143+
SQL string
144+
Str []string
145+
}
146+
statsSuiteData := GetCascadesSuiteData()
147+
statsSuiteData.LoadTestCases(t, &input, &output)
148+
for i, tt := range input {
149+
stmt, err := p.ParseOneStmt(tt, "", "")
150+
require.NoError(t, err, tt)
151+
ret := &plannercore.PreprocessorReturn{}
152+
nodeW := resolve.NewNodeW(stmt)
153+
err = plannercore.Preprocess(context.Background(), tk.Session(), nodeW, plannercore.WithPreprocessorReturn(ret))
154+
require.NoError(t, err)
155+
tk.Session().GetSessionVars().PlanColumnID.Store(0)
156+
builder, _ := plannercore.NewPlanBuilder().Init(tk.Session().GetPlanCtx(), ret.InfoSchema, hint.NewQBHintHandler(nil))
157+
p, err := builder.Build(ctx, nodeW)
158+
require.NoError(t, err, tt)
159+
p, err = plannercore.LogicalOptimizeTest(ctx, builder.GetOptFlag(), p.(base.LogicalPlan))
160+
require.NoError(t, err, tt)
161+
lp := p.(base.LogicalPlan)
162+
_, err = plannercore.RecursiveDeriveStats4Test(lp)
163+
require.NoError(t, err, tt)
164+
// after stats derive is done, which means the up-down propagation of group ndv is done, in bottom-up building phase
165+
// of memo, we don't have to expect the upper operator's group cols passing down anymore.
166+
mm := memo.NewMemo()
167+
mm.Init(lp)
168+
// check the stats state in memo group.
169+
b := &bytes.Buffer{}
170+
sb := util.NewStrBuffer(b)
171+
var strs []string
172+
mm.ForEachGroup(func(g *memo.Group) bool {
173+
b.Reset()
174+
// record group
175+
g.String(sb)
176+
sb.WriteString(", ")
177+
// record first ge
178+
g.ForEachGE(func(ge *memo.GroupExpression) bool {
179+
ge.String(sb)
180+
return false
181+
})
182+
sb.WriteString(", ")
183+
// record group stats
184+
logicProp := g.GetLogicalProperty()
185+
if logicProp == nil {
186+
sb.WriteString("logic prop:nil")
187+
} else {
188+
sb.WriteString("logic prop:{")
189+
if logicProp.Stats == nil {
190+
sb.WriteString("stats:nil,")
191+
} else {
192+
statsStr := fmt.Sprintf("count %v, ColNDVs %v, GroupNDVs %v", logicProp.Stats.RowCount, logicProp.Stats.ColNDVs, logicProp.Stats.GroupNDVs)
193+
sb.WriteString("stats:{" + statsStr + "}")
194+
}
195+
sb.WriteString(", ")
196+
if logicProp.Schema == nil {
197+
sb.WriteString("schema:nil")
198+
} else {
199+
sb.WriteString("schema:{" + logicProp.Schema.String() + "}")
200+
}
201+
sb.WriteString("}")
202+
}
203+
sb.Flush()
204+
strs = append(strs, b.String())
205+
return true
206+
})
207+
testdata.OnRecord(func() {
208+
output[i].SQL = tt
209+
output[i].Str = strs
210+
})
211+
require.Equal(t, output[i].Str, strs, "case i "+tt)
212+
}
213+
}

pkg/planner/core/casetest/cascades/testdata/cascades_suite_in.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,38 @@
5353
// DataSource -> Window -> Aggregation.
5454
"select count(tmp.a_sum) from (select t1.a as a, t1.b as b, sum(a) over() as a_sum from t1) tmp group by tmp.a, tmp.b"
5555
]
56+
},
57+
{
58+
"name": "TestGroupNDVCols",
59+
"cases": [
60+
// DataSource -> Aggregation.
61+
"select count(1) from t1 group by a, b",
62+
// DataSource -> Join.
63+
"select * from t1, t2 where t1.a = t2.a and t1.b = t2.b",
64+
// DataSource(Range) -> Aggregation.
65+
"select count(1) from t1 where a > 0 group by a, b",
66+
// DataSource(Selection) -> Aggregation.
67+
"select count(1) from t1 where b > 0 group by a, b",
68+
// DataSource -> Projection -> Aggregation.
69+
"select count(c3) from (select a as c1, b as c2, a+1 as c3 from t1) as tmp group by c2, c1",
70+
// DataSource -> Apply(LeftOuterJoin) -> Aggregation.
71+
"select count(tmp.cmp) from (select t1.a as a, t1.b as b, (t1.b > (select t2.b from t2 where t2.a = t1.a)) as cmp from t1) tmp group by tmp.a, tmp.b",
72+
// DataSource -> Apply(LeftOuterSemiJoin) -> Aggregation.
73+
"select count(tmp.cmp) from (select t1.a as a, t1.b as b, (t1.b in (select t2.b from t2 where t2.a = t1.a limit 3)) as cmp from t1) tmp group by tmp.a, tmp.b",
74+
// DataSource -> Apply(AntiLeftOuterSemiJoin) -> Aggregation.
75+
"select count(tmp.cmp) from (select t1.a as a, t1.b as b, (t1.b not in (select t2.b from t2 where t2.a = t1.a limit 3)) as cmp from t1) tmp group by tmp.a, tmp.b",
76+
// DataSource -> LeftOuterJoin -> Aggregation.
77+
"select count(1) from t1 left join t2 on t1.a = t2.a group by t1.a, t1.b",
78+
// DataSource -> RightOuterJoin -> Aggregation.
79+
"select count(1) from t1 right join t2 on t1.a = t2.a group by t2.a, t2.b",
80+
// DataSource -> LeftOuterSemiJoin -> Aggregation.
81+
"select count(tmp.cmp) from (select t1.a as a, t1.b as b, (t1.b in (select t2.b from t2 where t2.a > t1.a)) as cmp from t1) tmp group by tmp.a, tmp.b",
82+
// DataSource -> AntiLeftOuterSemiJoin -> Aggregation.
83+
"select count(tmp.cmp) from (select t1.a as a, t1.b as b, (t1.b not in (select t2.b from t2 where t2.a > t1.a)) as cmp from t1) tmp group by tmp.a, tmp.b",
84+
// DataSource -> Aggregation -> Join.
85+
"select * from t1 left join (select t2.a as a, t2.b as b, count(1) as cnt from t2 group by t2.a, t2.b) as tmp on t1.a = tmp.a and t1.b = tmp.b",
86+
// DataSource -> Window -> Aggregation.
87+
"select count(tmp.a_sum) from (select t1.a as a, t1.b as b, sum(a) over() as a_sum from t1) tmp group by tmp.a, tmp.b"
88+
]
5689
}
5790
]

pkg/planner/core/casetest/cascades/testdata/cascades_suite_out.json

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,5 +245,143 @@
245245
]
246246
}
247247
]
248+
},
249+
{
250+
"Name": "TestGroupNDVCols",
251+
"Cases": [
252+
{
253+
"SQL": "select count(1) from t1 group by a, b",
254+
"Str": [
255+
"GID:1, GE:DataSource_2{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
256+
"GID:2, GE:Aggregation_3{GID:1}, logic prop:{stats:{count 4, ColNDVs map[4:4], GroupNDVs []}, schema:{Column: [Column#4] PKOrUK: [] NullableUK: []}}",
257+
"GID:3, GE:Projection_4{GID:2}, logic prop:{stats:{count 4, ColNDVs map[4:4], GroupNDVs []}, schema:{Column: [Column#4] PKOrUK: [] NullableUK: []}}"
258+
]
259+
},
260+
{
261+
"SQL": "select * from t1, t2 where t1.a = t2.a and t1.b = t2.b",
262+
"Str": [
263+
"GID:1, GE:DataSource_5{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
264+
"GID:2, GE:DataSource_6{}, logic prop:{stats:{count 9, ColNDVs map[4:3 5:3], GroupNDVs [{[4 5] 9}]}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
265+
"GID:3, GE:Join_10{GID:1, GID:2}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2 4:3 5:3], GroupNDVs []}, schema:{Column: [test.t1.a,test.t1.b,test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
266+
"GID:4, GE:Projection_9{GID:3}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2 4:3 5:3], GroupNDVs []}, schema:{Column: [test.t1.a,test.t1.b,test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}"
267+
]
268+
},
269+
{
270+
"SQL": "select count(1) from t1 where a > 0 group by a, b",
271+
"Str": [
272+
"GID:1, GE:DataSource_11{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
273+
"GID:2, GE:Aggregation_13{GID:1}, logic prop:{stats:{count 4, ColNDVs map[4:4], GroupNDVs []}, schema:{Column: [Column#4] PKOrUK: [] NullableUK: []}}",
274+
"GID:3, GE:Projection_14{GID:2}, logic prop:{stats:{count 4, ColNDVs map[4:4], GroupNDVs []}, schema:{Column: [Column#4] PKOrUK: [] NullableUK: []}}"
275+
]
276+
},
277+
{
278+
"SQL": "select count(1) from t1 where b > 0 group by a, b",
279+
"Str": [
280+
"GID:1, GE:DataSource_15{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
281+
"GID:2, GE:Aggregation_17{GID:1}, logic prop:{stats:{count 4, ColNDVs map[4:4], GroupNDVs []}, schema:{Column: [Column#4] PKOrUK: [] NullableUK: []}}",
282+
"GID:3, GE:Projection_18{GID:2}, logic prop:{stats:{count 4, ColNDVs map[4:4], GroupNDVs []}, schema:{Column: [Column#4] PKOrUK: [] NullableUK: []}}"
283+
]
284+
},
285+
{
286+
"SQL": "select count(c3) from (select a as c1, b as c2, a+1 as c3 from t1) as tmp group by c2, c1",
287+
"Str": [
288+
"GID:1, GE:DataSource_19{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
289+
"GID:2, GE:Aggregation_21{GID:1}, logic prop:{stats:{count 4, ColNDVs map[5:4], GroupNDVs []}, schema:{Column: [Column#5] PKOrUK: [] NullableUK: []}}",
290+
"GID:3, GE:Projection_22{GID:2}, logic prop:{stats:{count 4, ColNDVs map[5:4], GroupNDVs []}, schema:{Column: [Column#5] PKOrUK: [] NullableUK: []}}"
291+
]
292+
},
293+
{
294+
"SQL": "select count(tmp.cmp) from (select t1.a as a, t1.b as b, (t1.b > (select t2.b from t2 where t2.a = t1.a)) as cmp from t1) tmp group by tmp.a, tmp.b",
295+
"Str": [
296+
"GID:1, GE:DataSource_23{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
297+
"GID:2, GE:DataSource_26{}, logic prop:{stats:{count 3, ColNDVs map[7:1 8:1], GroupNDVs []}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
298+
"GID:3, GE:MaxOneRow_29{GID:2}, logic prop:{stats:{count 1, ColNDVs map[7:1 8:1], GroupNDVs []}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
299+
"GID:4, GE:Apply_30{GID:1, GID:3}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2 7:4 8:4], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b,test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
300+
"GID:5, GE:Aggregation_31{GID:4}, logic prop:{stats:{count 4, ColNDVs map[11:4], GroupNDVs []}, schema:{Column: [Column#11] PKOrUK: [] NullableUK: []}}",
301+
"GID:6, GE:Projection_32{GID:5}, logic prop:{stats:{count 4, ColNDVs map[11:4], GroupNDVs []}, schema:{Column: [Column#11] PKOrUK: [] NullableUK: []}}"
302+
]
303+
},
304+
{
305+
"SQL": "select count(tmp.cmp) from (select t1.a as a, t1.b as b, (t1.b in (select t2.b from t2 where t2.a = t1.a limit 3)) as cmp from t1) tmp group by tmp.a, tmp.b",
306+
"Str": [
307+
"GID:1, GE:DataSource_33{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
308+
"GID:2, GE:DataSource_36{}, logic prop:{stats:{count 3, ColNDVs map[7:1 8:1], GroupNDVs []}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
309+
"GID:3, GE:Limit_44{GID:2}, logic prop:{stats:{count 3, ColNDVs map[7:1 8:1], GroupNDVs []}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
310+
"GID:4, GE:Apply_40{GID:1, GID:3}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2 10:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b,Column#10] PKOrUK: [] NullableUK: []}}",
311+
"GID:5, GE:Aggregation_41{GID:4}, logic prop:{stats:{count 4, ColNDVs map[11:4], GroupNDVs []}, schema:{Column: [Column#11] PKOrUK: [] NullableUK: []}}",
312+
"GID:6, GE:Projection_42{GID:5}, logic prop:{stats:{count 4, ColNDVs map[11:4], GroupNDVs []}, schema:{Column: [Column#11] PKOrUK: [] NullableUK: []}}"
313+
]
314+
},
315+
{
316+
"SQL": "select count(tmp.cmp) from (select t1.a as a, t1.b as b, (t1.b not in (select t2.b from t2 where t2.a = t1.a limit 3)) as cmp from t1) tmp group by tmp.a, tmp.b",
317+
"Str": [
318+
"GID:1, GE:DataSource_45{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
319+
"GID:2, GE:DataSource_48{}, logic prop:{stats:{count 3, ColNDVs map[7:1 8:1], GroupNDVs []}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
320+
"GID:3, GE:Limit_56{GID:2}, logic prop:{stats:{count 3, ColNDVs map[7:1 8:1], GroupNDVs []}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
321+
"GID:4, GE:Apply_52{GID:1, GID:3}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2 10:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b,Column#10] PKOrUK: [] NullableUK: []}}",
322+
"GID:5, GE:Aggregation_53{GID:4}, logic prop:{stats:{count 4, ColNDVs map[11:4], GroupNDVs []}, schema:{Column: [Column#11] PKOrUK: [] NullableUK: []}}",
323+
"GID:6, GE:Projection_54{GID:5}, logic prop:{stats:{count 4, ColNDVs map[11:4], GroupNDVs []}, schema:{Column: [Column#11] PKOrUK: [] NullableUK: []}}"
324+
]
325+
},
326+
{
327+
"SQL": "select count(1) from t1 left join t2 on t1.a = t2.a group by t1.a, t1.b",
328+
"Str": [
329+
"GID:1, GE:DataSource_57{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
330+
"GID:2, GE:DataSource_58{}, logic prop:{stats:{count 9, ColNDVs map[4:3], GroupNDVs []}, schema:{Column: [test.t2.a] PKOrUK: [] NullableUK: []}}",
331+
"GID:3, GE:Join_62{GID:1, GID:2}, logic prop:{stats:{count 12, ColNDVs map[1:2 2:2 4:3], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b,test.t2.a] PKOrUK: [] NullableUK: []}}",
332+
"GID:4, GE:Aggregation_60{GID:3}, logic prop:{stats:{count 4, ColNDVs map[7:4], GroupNDVs []}, schema:{Column: [Column#7] PKOrUK: [] NullableUK: []}}",
333+
"GID:5, GE:Projection_61{GID:4}, logic prop:{stats:{count 4, ColNDVs map[7:4], GroupNDVs []}, schema:{Column: [Column#7] PKOrUK: [] NullableUK: []}}"
334+
]
335+
},
336+
{
337+
"SQL": "select count(1) from t1 right join t2 on t1.a = t2.a group by t2.a, t2.b",
338+
"Str": [
339+
"GID:1, GE:DataSource_63{}, logic prop:{stats:{count 4, ColNDVs map[1:2], GroupNDVs []}, schema:{Column: [test.t1.a] PKOrUK: [] NullableUK: []}}",
340+
"GID:2, GE:DataSource_64{}, logic prop:{stats:{count 9, ColNDVs map[4:3 5:3], GroupNDVs [{[4 5] 9}]}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
341+
"GID:3, GE:Join_68{GID:1, GID:2}, logic prop:{stats:{count 12, ColNDVs map[1:2 4:3 5:3], GroupNDVs [{[4 5] 9}]}, schema:{Column: [test.t1.a,test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
342+
"GID:4, GE:Aggregation_66{GID:3}, logic prop:{stats:{count 9, ColNDVs map[7:9], GroupNDVs []}, schema:{Column: [Column#7] PKOrUK: [] NullableUK: []}}",
343+
"GID:5, GE:Projection_67{GID:4}, logic prop:{stats:{count 9, ColNDVs map[7:9], GroupNDVs []}, schema:{Column: [Column#7] PKOrUK: [] NullableUK: []}}"
344+
]
345+
},
346+
{
347+
"SQL": "select count(tmp.cmp) from (select t1.a as a, t1.b as b, (t1.b in (select t2.b from t2 where t2.a > t1.a)) as cmp from t1) tmp group by tmp.a, tmp.b",
348+
"Str": [
349+
"GID:1, GE:DataSource_69{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
350+
"GID:2, GE:DataSource_72{}, logic prop:{stats:{count 9, ColNDVs map[7:3 8:3], GroupNDVs []}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
351+
"GID:3, GE:Join_75{GID:1, GID:2}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2 10:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b,Column#10] PKOrUK: [] NullableUK: []}}",
352+
"GID:4, GE:Aggregation_76{GID:3}, logic prop:{stats:{count 4, ColNDVs map[11:4], GroupNDVs []}, schema:{Column: [Column#11] PKOrUK: [] NullableUK: []}}",
353+
"GID:5, GE:Projection_77{GID:4}, logic prop:{stats:{count 4, ColNDVs map[11:4], GroupNDVs []}, schema:{Column: [Column#11] PKOrUK: [] NullableUK: []}}"
354+
]
355+
},
356+
{
357+
"SQL": "select count(tmp.cmp) from (select t1.a as a, t1.b as b, (t1.b not in (select t2.b from t2 where t2.a > t1.a)) as cmp from t1) tmp group by tmp.a, tmp.b",
358+
"Str": [
359+
"GID:1, GE:DataSource_78{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
360+
"GID:2, GE:DataSource_81{}, logic prop:{stats:{count 9, ColNDVs map[7:3 8:3], GroupNDVs []}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
361+
"GID:3, GE:Join_84{GID:1, GID:2}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2 10:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b,Column#10] PKOrUK: [] NullableUK: []}}",
362+
"GID:4, GE:Aggregation_85{GID:3}, logic prop:{stats:{count 4, ColNDVs map[11:4], GroupNDVs []}, schema:{Column: [Column#11] PKOrUK: [] NullableUK: []}}",
363+
"GID:5, GE:Projection_86{GID:4}, logic prop:{stats:{count 4, ColNDVs map[11:4], GroupNDVs []}, schema:{Column: [Column#11] PKOrUK: [] NullableUK: []}}"
364+
]
365+
},
366+
{
367+
"SQL": "select * from t1 left join (select t2.a as a, t2.b as b, count(1) as cnt from t2 group by t2.a, t2.b) as tmp on t1.a = tmp.a and t1.b = tmp.b",
368+
"Str": [
369+
"GID:1, GE:DataSource_87{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
370+
"GID:2, GE:DataSource_88{}, logic prop:{stats:{count 9, ColNDVs map[4:3 5:3], GroupNDVs [{[4 5] 9}]}, schema:{Column: [test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
371+
"GID:3, GE:Aggregation_89{GID:2}, logic prop:{stats:{count 9, ColNDVs map[4:9 5:9 7:9], GroupNDVs [{[4 5] 9}]}, schema:{Column: [Column#7,test.t2.a,test.t2.b] PKOrUK: [[test.t2.a,test.t2.b]] NullableUK: []}}",
372+
"GID:4, GE:Join_93{GID:1, GID:3}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2 4:4 5:4 7:4], GroupNDVs []}, schema:{Column: [test.t1.a,test.t1.b,Column#7,test.t2.a,test.t2.b] PKOrUK: [] NullableUK: []}}",
373+
"GID:5, GE:Projection_92{GID:4}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2 4:4 5:4 7:4], GroupNDVs []}, schema:{Column: [test.t1.a,test.t1.b,test.t2.a,test.t2.b,Column#7] PKOrUK: [] NullableUK: []}}"
374+
]
375+
},
376+
{
377+
"SQL": "select count(tmp.a_sum) from (select t1.a as a, t1.b as b, sum(a) over() as a_sum from t1) tmp group by tmp.a, tmp.b",
378+
"Str": [
379+
"GID:1, GE:DataSource_94{}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b] PKOrUK: [] NullableUK: []}}",
380+
"GID:2, GE:Window_97{GID:1}, logic prop:{stats:{count 4, ColNDVs map[1:2 2:2 5:4], GroupNDVs [{[1 2] 4}]}, schema:{Column: [test.t1.a,test.t1.b,Column#5] PKOrUK: [] NullableUK: []}}",
381+
"GID:3, GE:Aggregation_99{GID:2}, logic prop:{stats:{count 4, ColNDVs map[6:4], GroupNDVs []}, schema:{Column: [Column#6] PKOrUK: [] NullableUK: []}}",
382+
"GID:4, GE:Projection_100{GID:3}, logic prop:{stats:{count 4, ColNDVs map[6:4], GroupNDVs []}, schema:{Column: [Column#6] PKOrUK: [] NullableUK: []}}"
383+
]
384+
}
385+
]
248386
}
249387
]

0 commit comments

Comments
 (0)