Skip to content

Commit 3d0e1b6

Browse files
committed
Update expected plans for timechart
Signed-off-by: Yuanchun Shen <[email protected]>
1 parent 32ee1ea commit 3d0e1b6

File tree

4 files changed

+105
-176
lines changed

4 files changed

+105
-176
lines changed

integ-test/src/test/resources/expectedOutput/calcite/explain_timechart.yaml

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,38 @@ calcite:
33
LogicalSystemLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[10000], type=[QUERY_SIZE_LIMIT])
44
LogicalSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC])
55
LogicalAggregate(group=[{0, 1}], avg(cpu_usage)=[AVG($2)])
6-
LogicalProject(@timestamp=[$0], host=[CASE(IS NOT NULL($3), $1, CASE(IS NULL($1), null:NULL, 'OTHER'))], avg(cpu_usage)=[$2])
6+
LogicalProject(@timestamp=[$0], host=[CASE(IS NULL($1), 'NULL', <=($5, 10), $1, 'OTHER')], avg(cpu_usage)=[$2])
77
LogicalJoin(condition=[=($1, $3)], joinType=[left])
8-
LogicalProject(@timestamp=[$1], host=[$0], $f2=[$2])
9-
LogicalAggregate(group=[{0, 2}], agg#0=[AVG($1)])
10-
LogicalProject(host=[$4], cpu_usage=[$7], $f3=[SPAN($1, 1, 'm')])
11-
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
12-
LogicalSort(sort0=[$1], dir0=[DESC], fetch=[10])
13-
LogicalAggregate(group=[{1}], grand_total=[AVG($2)])
14-
LogicalFilter(condition=[IS NOT NULL($1)])
15-
LogicalProject(@timestamp=[$1], host=[$0], $f2=[$2])
16-
LogicalAggregate(group=[{0, 2}], agg#0=[AVG($1)])
17-
LogicalProject(host=[$4], cpu_usage=[$7], $f3=[SPAN($1, 1, 'm')])
18-
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
8+
LogicalProject(@timestamp=[$1], host=[$0], avg(cpu_usage)=[$2])
9+
LogicalAggregate(group=[{0, 2}], avg(cpu_usage)=[AVG($1)])
10+
LogicalProject(host=[$4], cpu_usage=[$7], @timestamp0=[SPAN($1, 1, 'm')])
11+
LogicalFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($7))])
12+
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
13+
LogicalProject(host=[$0], __grand_total__=[$1], _row_number_chart_=[ROW_NUMBER() OVER (ORDER BY $1 DESC NULLS LAST)])
14+
LogicalAggregate(group=[{0}], __grand_total__=[SUM($1)])
15+
LogicalFilter(condition=[IS NOT NULL($0)])
16+
LogicalProject(host=[$0], avg(cpu_usage)=[$2])
17+
LogicalAggregate(group=[{0, 2}], avg(cpu_usage)=[AVG($1)])
18+
LogicalProject(host=[$4], cpu_usage=[$7], @timestamp0=[SPAN($1, 1, 'm')])
19+
LogicalFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($7))])
20+
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
1921
physical: |
2022
EnumerableLimit(fetch=[10000])
2123
EnumerableSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC])
2224
EnumerableCalc(expr#0..3=[{inputs}], expr#4=[0], expr#5=[=($t3, $t4)], expr#6=[null:DOUBLE], expr#7=[CASE($t5, $t6, $t2)], expr#8=[/($t7, $t3)], proj#0..1=[{exprs}], avg(cpu_usage)=[$t8])
2325
EnumerableAggregate(group=[{0, 1}], agg#0=[$SUM0($2)], agg#1=[COUNT($2)])
24-
EnumerableCalc(expr#0..4=[{inputs}], expr#5=[IS NOT NULL($t3)], expr#6=[IS NULL($t1)], expr#7=[null:NULL], expr#8=['OTHER'], expr#9=[CASE($t6, $t7, $t8)], expr#10=[CASE($t5, $t1, $t9)], @timestamp=[$t0], host=[$t10], avg(cpu_usage)=[$t2])
26+
EnumerableCalc(expr#0..4=[{inputs}], expr#5=[IS NULL($t1)], expr#6=['NULL'], expr#7=[10], expr#8=[<=($t4, $t7)], expr#9=['OTHER'], expr#10=[CASE($t5, $t6, $t8, $t1, $t9)], @timestamp=[$t0], host=[$t10], avg(cpu_usage)=[$t2])
2527
EnumerableMergeJoin(condition=[=($1, $3)], joinType=[left])
2628
EnumerableSort(sort0=[$1], dir0=[ASC])
27-
EnumerableCalc(expr#0..3=[{inputs}], expr#4=[0], expr#5=[=($t3, $t4)], expr#6=[null:DOUBLE], expr#7=[CASE($t5, $t6, $t2)], expr#8=[/($t7, $t3)], @timestamp=[$t1], host=[$t0], $f2=[$t8])
29+
EnumerableCalc(expr#0..3=[{inputs}], expr#4=[0], expr#5=[=($t3, $t4)], expr#6=[null:DOUBLE], expr#7=[CASE($t5, $t6, $t2)], expr#8=[/($t7, $t3)], @timestamp=[$t1], host=[$t0], avg(cpu_usage)=[$t8])
2830
EnumerableAggregate(group=[{0, 2}], agg#0=[$SUM0($1)], agg#1=[COUNT($1)])
29-
EnumerableCalc(expr#0..2=[{inputs}], expr#3=[1], expr#4=['m'], expr#5=[SPAN($t2, $t3, $t4)], proj#0..1=[{exprs}], $f2=[$t5])
30-
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[PROJECT->[host, cpu_usage, @timestamp]], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","_source":{"includes":["host","cpu_usage","@timestamp"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])
31+
EnumerableCalc(expr#0..2=[{inputs}], expr#3=[1], expr#4=['m'], expr#5=[SPAN($t0, $t3, $t4)], host=[$t1], cpu_usage=[$t2], @timestamp0=[$t5])
32+
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[PROJECT->[@timestamp, host, cpu_usage], FILTER->AND(IS NOT NULL($0), IS NOT NULL($2))], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","query":{"bool":{"must":[{"exists":{"field":"@timestamp","boost":1.0}},{"exists":{"field":"cpu_usage","boost":1.0}}],"adjust_pure_negative":true,"boost":1.0}},"_source":{"includes":["@timestamp","host","cpu_usage"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])
3133
EnumerableSort(sort0=[$0], dir0=[ASC])
32-
EnumerableLimit(fetch=[10])
33-
EnumerableSort(sort0=[$1], dir0=[DESC])
34-
EnumerableCalc(expr#0..2=[{inputs}], expr#3=[0], expr#4=[=($t2, $t3)], expr#5=[null:DOUBLE], expr#6=[CASE($t4, $t5, $t1)], expr#7=[/($t6, $t2)], host=[$t0], grand_total=[$t7])
35-
EnumerableAggregate(group=[{0}], agg#0=[$SUM0($1)], agg#1=[COUNT($1)])
36-
EnumerableCalc(expr#0..3=[{inputs}], expr#4=[0], expr#5=[=($t3, $t4)], expr#6=[null:DOUBLE], expr#7=[CASE($t5, $t6, $t2)], expr#8=[/($t7, $t3)], host=[$t0], $f2=[$t8])
37-
EnumerableAggregate(group=[{0, 2}], agg#0=[$SUM0($1)], agg#1=[COUNT($1)])
38-
EnumerableCalc(expr#0..2=[{inputs}], expr#3=[1], expr#4=['m'], expr#5=[SPAN($t2, $t3, $t4)], proj#0..1=[{exprs}], $f2=[$t5])
39-
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[PROJECT->[host, cpu_usage, @timestamp], FILTER->IS NOT NULL($0)], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","query":{"exists":{"field":"host","boost":1.0}},"_source":{"includes":["host","cpu_usage","@timestamp"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])
34+
EnumerableCalc(expr#0..2=[{inputs}], host=[$t0], $1=[$t2])
35+
EnumerableWindow(window#0=[window(order by [1 DESC-nulls-last] rows between UNBOUNDED PRECEDING and CURRENT ROW aggs [ROW_NUMBER()])])
36+
EnumerableAggregate(group=[{0}], __grand_total__=[SUM($1)])
37+
EnumerableCalc(expr#0..3=[{inputs}], expr#4=[0], expr#5=[=($t3, $t4)], expr#6=[null:DOUBLE], expr#7=[CASE($t5, $t6, $t2)], expr#8=[/($t7, $t3)], host=[$t0], avg(cpu_usage)=[$t8])
38+
EnumerableAggregate(group=[{0, 2}], agg#0=[$SUM0($1)], agg#1=[COUNT($1)])
39+
EnumerableCalc(expr#0..2=[{inputs}], expr#3=[1], expr#4=['m'], expr#5=[SPAN($t0, $t3, $t4)], host=[$t1], cpu_usage=[$t2], @timestamp0=[$t5])
40+
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[PROJECT->[@timestamp, host, cpu_usage], FILTER->AND(IS NOT NULL($0), IS NOT NULL($2)), FILTER->IS NOT NULL($1)], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","query":{"bool":{"filter":[{"bool":{"must":[{"exists":{"field":"@timestamp","boost":1.0}},{"exists":{"field":"cpu_usage","boost":1.0}}],"adjust_pure_negative":true,"boost":1.0}},{"exists":{"field":"host","boost":1.0}}],"adjust_pure_negative":true,"boost":1.0}},"_source":{"includes":["@timestamp","host","cpu_usage"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])

integ-test/src/test/resources/expectedOutput/calcite/explain_timechart_count.yaml

Lines changed: 28 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,35 @@ calcite:
22
logical: |
33
LogicalSystemLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[10000], type=[QUERY_SIZE_LIMIT])
44
LogicalSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC])
5-
LogicalAggregate(group=[{0, 1}], count=[SUM($2)])
6-
LogicalUnion(all=[false])
7-
LogicalAggregate(group=[{0, 1}], actual_count=[SUM($2)])
8-
LogicalProject(@timestamp=[CAST($0):TIMESTAMP(0) NOT NULL], host=[CASE(IS NOT NULL($3), $1, CASE(IS NULL($1), null:NULL, 'OTHER'))], count=[$2])
9-
LogicalJoin(condition=[IS NOT DISTINCT FROM($1, $3)], joinType=[left])
10-
LogicalProject(@timestamp=[$1], host=[$0], $f2_0=[$2])
11-
LogicalAggregate(group=[{0, 1}], agg#0=[COUNT()])
12-
LogicalProject(host=[$4], $f2=[SPAN($1, 1, 'm')])
13-
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
14-
LogicalSort(sort0=[$1], dir0=[DESC], fetch=[10])
15-
LogicalAggregate(group=[{1}], grand_total=[SUM($2)])
16-
LogicalFilter(condition=[IS NOT NULL($1)])
17-
LogicalProject(@timestamp=[$1], host=[$0], $f2_0=[$2])
18-
LogicalAggregate(group=[{0, 1}], agg#0=[COUNT()])
19-
LogicalProject(host=[$4], $f2=[SPAN($1, 1, 'm')])
20-
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
21-
LogicalProject(@timestamp=[CAST($0):TIMESTAMP(0) NOT NULL], host=[$1], count=[0])
22-
LogicalJoin(condition=[true], joinType=[inner])
23-
LogicalAggregate(group=[{0}])
24-
LogicalProject(@timestamp=[$1])
25-
LogicalAggregate(group=[{0, 1}], agg#0=[COUNT()])
26-
LogicalProject(host=[$4], $f2=[SPAN($1, 1, 'm')])
27-
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
28-
LogicalAggregate(group=[{0}])
29-
LogicalProject($f0=[CASE(IS NOT NULL($3), $1, CASE(IS NULL($1), null:NULL, 'OTHER'))])
30-
LogicalJoin(condition=[IS NOT DISTINCT FROM($1, $3)], joinType=[left])
31-
LogicalProject(@timestamp=[$1], host=[$0], $f2_0=[$2])
32-
LogicalAggregate(group=[{0, 1}], agg#0=[COUNT()])
33-
LogicalProject(host=[$4], $f2=[SPAN($1, 1, 'm')])
34-
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
35-
LogicalSort(sort0=[$1], dir0=[DESC], fetch=[10])
36-
LogicalAggregate(group=[{1}], grand_total=[SUM($2)])
5+
LogicalAggregate(group=[{0, 1}], count()=[SUM($2)])
6+
LogicalProject(@timestamp=[$0], host=[CASE(IS NULL($1), 'NULL', <=($5, 10), $1, 'OTHER')], count()=[$2])
7+
LogicalJoin(condition=[=($1, $3)], joinType=[left])
8+
LogicalProject(@timestamp=[$1], host=[$0], count()=[$2])
9+
LogicalAggregate(group=[{0, 1}], count()=[COUNT()])
10+
LogicalProject(host=[$4], @timestamp0=[SPAN($1, 1, 'm')])
11+
LogicalFilter(condition=[IS NOT NULL($1)])
12+
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
13+
LogicalProject(host=[$0], __grand_total__=[$1], _row_number_chart_=[ROW_NUMBER() OVER (ORDER BY $1 DESC NULLS LAST)])
14+
LogicalAggregate(group=[{0}], __grand_total__=[SUM($1)])
15+
LogicalFilter(condition=[IS NOT NULL($0)])
16+
LogicalProject(host=[$0], count()=[$2])
17+
LogicalAggregate(group=[{0, 1}], count()=[COUNT()])
18+
LogicalProject(host=[$4], @timestamp0=[SPAN($1, 1, 'm')])
3719
LogicalFilter(condition=[IS NOT NULL($1)])
38-
LogicalProject(@timestamp=[$1], host=[$0], $f2_0=[$2])
39-
LogicalAggregate(group=[{0, 1}], agg#0=[COUNT()])
40-
LogicalProject(host=[$4], $f2=[SPAN($1, 1, 'm')])
41-
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
20+
CalciteLogicalIndexScan(table=[[OpenSearch, events]])
4221
physical: |
4322
EnumerableLimit(fetch=[10000])
4423
EnumerableSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC])
45-
EnumerableAggregate(group=[{0, 1}], count=[$SUM0($2)])
46-
EnumerableUnion(all=[false])
47-
EnumerableAggregate(group=[{0, 1}], actual_count=[$SUM0($2)])
48-
EnumerableCalc(expr#0..4=[{inputs}], expr#5=[CAST($t0):TIMESTAMP(0) NOT NULL], expr#6=[IS NOT NULL($t3)], expr#7=[IS NULL($t1)], expr#8=[null:NULL], expr#9=['OTHER'], expr#10=[CASE($t7, $t8, $t9)], expr#11=[CASE($t6, $t1, $t10)], @timestamp=[$t5], host=[$t11], count=[$t2])
49-
EnumerableNestedLoopJoin(condition=[IS NOT DISTINCT FROM($1, $3)], joinType=[left])
50-
EnumerableCalc(expr#0..2=[{inputs}], @timestamp=[$t1], host=[$t0], $f2_0=[$t2])
51-
EnumerableAggregate(group=[{0, 1}], agg#0=[COUNT()])
52-
EnumerableCalc(expr#0..1=[{inputs}], expr#2=[1], expr#3=['m'], expr#4=[SPAN($t1, $t2, $t3)], host=[$t0], $f1=[$t4])
53-
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[PROJECT->[host, @timestamp]], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","_source":{"includes":["host","@timestamp"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])
54-
EnumerableLimit(fetch=[10])
55-
EnumerableSort(sort0=[$1], dir0=[DESC])
56-
EnumerableAggregate(group=[{0}], grand_total=[COUNT()])
57-
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[PROJECT->[host, @timestamp], FILTER->IS NOT NULL($0)], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","query":{"exists":{"field":"host","boost":1.0}},"_source":{"includes":["host","@timestamp"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])
58-
EnumerableCalc(expr#0..1=[{inputs}], expr#2=[CAST($t0):TIMESTAMP(0) NOT NULL], expr#3=[0], @timestamp=[$t2], host=[$t1], count=[$t3])
59-
EnumerableNestedLoopJoin(condition=[true], joinType=[inner])
60-
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[AGGREGATION->rel#:LogicalAggregate.NONE.[](input=RelSubset#,group={1})], OpenSearchRequestBuilder(sourceBuilder={"from":0,"size":0,"timeout":"1m","aggregations":{"composite_buckets":{"composite":{"size":1000,"sources":[{"$f2":{"date_histogram":{"field":"@timestamp","missing_bucket":false,"order":"asc","fixed_interval":"1m"}}}]}}}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])
61-
EnumerableAggregate(group=[{0}])
62-
EnumerableCalc(expr#0..2=[{inputs}], expr#3=[IS NOT NULL($t1)], expr#4=[IS NULL($t0)], expr#5=[null:NULL], expr#6=['OTHER'], expr#7=[CASE($t4, $t5, $t6)], expr#8=[CASE($t3, $t0, $t7)], $f0=[$t8])
63-
EnumerableNestedLoopJoin(condition=[IS NOT DISTINCT FROM($0, $1)], joinType=[left])
64-
EnumerableCalc(expr#0..1=[{inputs}], host=[$t0])
65-
EnumerableAggregate(group=[{0, 1}])
66-
EnumerableCalc(expr#0..1=[{inputs}], expr#2=[1], expr#3=['m'], expr#4=[SPAN($t1, $t2, $t3)], host=[$t0], $f1=[$t4])
67-
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[PROJECT->[host, @timestamp]], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","_source":{"includes":["host","@timestamp"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])
68-
EnumerableLimit(fetch=[10])
69-
EnumerableSort(sort0=[$1], dir0=[DESC])
70-
EnumerableAggregate(group=[{0}], grand_total=[COUNT()])
71-
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[PROJECT->[host, @timestamp], FILTER->IS NOT NULL($0)], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","query":{"exists":{"field":"host","boost":1.0}},"_source":{"includes":["host","@timestamp"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])
24+
EnumerableAggregate(group=[{0, 1}], count()=[$SUM0($2)])
25+
EnumerableCalc(expr#0..4=[{inputs}], expr#5=[IS NULL($t1)], expr#6=['NULL'], expr#7=[10], expr#8=[<=($t4, $t7)], expr#9=['OTHER'], expr#10=[CASE($t5, $t6, $t8, $t1, $t9)], @timestamp=[$t0], host=[$t10], count()=[$t2])
26+
EnumerableMergeJoin(condition=[=($1, $3)], joinType=[left])
27+
EnumerableSort(sort0=[$1], dir0=[ASC])
28+
EnumerableCalc(expr#0..2=[{inputs}], @timestamp=[$t1], host=[$t0], count()=[$t2])
29+
EnumerableAggregate(group=[{0, 1}], count()=[COUNT()])
30+
EnumerableCalc(expr#0..1=[{inputs}], expr#2=[1], expr#3=['m'], expr#4=[SPAN($t0, $t2, $t3)], host=[$t1], @timestamp0=[$t4])
31+
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[PROJECT->[@timestamp, host], FILTER->IS NOT NULL($0)], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","query":{"exists":{"field":"@timestamp","boost":1.0}},"_source":{"includes":["@timestamp","host"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])
32+
EnumerableSort(sort0=[$0], dir0=[ASC])
33+
EnumerableCalc(expr#0..2=[{inputs}], host=[$t0], $1=[$t2])
34+
EnumerableWindow(window#0=[window(order by [1 DESC-nulls-last] rows between UNBOUNDED PRECEDING and CURRENT ROW aggs [ROW_NUMBER()])])
35+
EnumerableAggregate(group=[{1}], __grand_total__=[COUNT()])
36+
CalciteEnumerableIndexScan(table=[[OpenSearch, events]], PushDownContext=[[PROJECT->[@timestamp, host], FILTER->IS NOT NULL($0), FILTER->IS NOT NULL($1)], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","query":{"bool":{"filter":[{"exists":{"field":"@timestamp","boost":1.0}},{"exists":{"field":"host","boost":1.0}}],"adjust_pure_negative":true,"boost":1.0}},"_source":{"includes":["@timestamp","host"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])

0 commit comments

Comments
 (0)