Skip to content

Commit

Permalink
planner: Add explain info for InspectionRuleTableExtractor (#16087)
Browse files Browse the repository at this point in the history
  • Loading branch information
b41sh authored Apr 7, 2020
1 parent c31e4be commit 38d9711
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions executor/explainfor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,13 @@ func (s *testSuite) TestExplainMetricTable(c *C) {
tk.MustQuery("desc select * from information_schema.cluster_log where type in ('high_cpu_1','high_memory_1') and time >= '2019-12-23 16:10:13' and time <= '2019-12-23 16:30:13'").Check(testkit.Rows(
`MemTableScan_5 10000.00 root table:CLUSTER_LOG start_time:2019-12-23 16:10:13, end_time:2019-12-23 16:30:13, node_types:["high_cpu_1","high_memory_1"]`))
}

func (s *testSuite) TestInspectionRuleTable(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.inspection_rules where type='inspection'")).Check(testkit.Rows(
`MemTableScan_5 10000.00 root table:INSPECTION_RULES node_types:["inspection"]`))
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.inspection_rules where type='inspection' or type='summary'")).Check(testkit.Rows(
`MemTableScan_5 10000.00 root table:INSPECTION_RULES node_types:["inspection","summary"]`))
tk.MustQuery(fmt.Sprintf("desc select * from information_schema.inspection_rules where type='inspection' and type='summary'")).Check(testkit.Rows(
`MemTableScan_5 10000.00 root table:INSPECTION_RULES skip_request: true`))
}
10 changes: 9 additions & 1 deletion planner/core/memtable_predicate_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,15 @@ func (e *InspectionRuleTableExtractor) Extract(
}

func (e *InspectionRuleTableExtractor) explainInfo(p *PhysicalMemTable) string {
return ""
if e.SkipRequest {
return "skip_request: true"
}

r := new(bytes.Buffer)
if len(e.Types) > 0 {
r.WriteString(fmt.Sprintf("node_types:[%s]", extractStringFromStringSet(e.Types)))
}
return r.String()
}

// SlowQueryExtractor is used to extract some predicates of `slow_query`
Expand Down

0 comments on commit 38d9711

Please sign in to comment.