This commit is contained in:
Zoltan Haindrich 2024-12-04 17:19:30 +00:00
parent 6d577f8468
commit 3f3335f6fe
3 changed files with 49 additions and 17 deletions

22
s Normal file
View File

@ -0,0 +1,22 @@
2024-12-04T16:38:13,926 INFO [main] org.apache.druid.sql.calcite.planner.CalciteRulesManager - __decAfterTrim1
LogicalProject(arrayString=[CAST(ARRAY('a':VARCHAR, 'b':VARCHAR)):VARCHAR ARRAY], uln=[$1], udn=[$2], usn=[$3]): rowcount = 3.75, cumulative cost = {inf}, id = 1092
LogicalCorrelate(correlation=[$cor2], joinType=[inner], requiredColumns=[{0}]): rowcount = 3.75, cumulative cost = {inf}, id = 1091
LogicalProject(arrayStringNulls=[$0], uln=[$2], udn=[$3]): rowcount = 3.75, cumulative cost = {inf}, id = 1085
LogicalFilter(condition=[OR(=($2, 1), =($3, 2.2))]): rowcount = 3.75, cumulative cost = {inf}, id = 1084
LogicalCorrelate(correlation=[$cor1], joinType=[inner], requiredColumns=[{1}]): rowcount = 15.0, cumulative cost = {inf}, id = 1083
LogicalProject(arrayStringNulls=[$0], arrayDoubleNulls=[$2], uln=[$3]): rowcount = 15.0, cumulative cost = {inf}, id = 1079
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{1}]): rowcount = 15.0, cumulative cost = {inf}, id = 1078
LogicalProject(arrayStringNulls=[$1], arrayLongNulls=[$2], arrayDoubleNulls=[$3]): rowcount = 15.0, cumulative cost = {230.0 rows, 646.0 cpu, 0.0 io}, id = 1074
LogicalFilter(condition=[=($0, CAST(ARRAY('a', 'b')):VARCHAR ARRAY NOT NULL)]): rowcount = 15.0, cumulative cost = {215.0 rows, 601.0 cpu, 0.0 io}, id = 1073
LogicalProject(arrayString=[$1], arrayStringNulls=[$2], arrayLongNulls=[$4], arrayDoubleNulls=[$6]): rowcount = 100.0, cumulative cost = {200.0 rows, 501.0 cpu, 0.0 io}, id = 1072
LogicalTableScan(table=[[druid, arrays]]): rowcount = 100.0, cumulative cost = {100.0 rows, 101.0 cpu, 0.0 io}, id = 640
Uncollect: rowcount = 1.0, cumulative cost = {3.0 rows, 3.0 cpu, 0.0 io}, id = 1077
LogicalProject(arrayLongNulls=[$cor0.arrayLongNulls]): rowcount = 1.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 1076
LogicalValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 641
Uncollect: rowcount = 1.0, cumulative cost = {3.0 rows, 3.0 cpu, 0.0 io}, id = 1082
LogicalProject(arrayDoubleNulls=[$cor1.arrayDoubleNulls]): rowcount = 1.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 1081
LogicalValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 647
LogicalFilter(condition=[=($0, 'a')]): rowcount = 1.0, cumulative cost = {4.0 rows, 4.0 cpu, 0.0 io}, id = 1090
Uncollect: rowcount = 1.0, cumulative cost = {3.0 rows, 3.0 cpu, 0.0 io}, id = 1089
LogicalProject(arrayStringNulls=[$cor2.arrayStringNulls]): rowcount = 1.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 1088
LogicalValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 653

22
s2 Normal file
View File

@ -0,0 +1,22 @@
2024-12-04T16:50:39,077 INFO [main] org.apache.druid.sql.calcite.planner.CalciteRulesManager - __decAfterTrim1
LogicalProject(arrayString=[CAST(ARRAY('a':VARCHAR, 'b':VARCHAR)):VARCHAR ARRAY], uln=[$1], udn=[$2], usn=[$3]): rowcount = 3.75, cumulative cost = {inf}, id = 1072
LogicalCorrelate(correlation=[$cor2], joinType=[inner], requiredColumns=[{0}]): rowcount = 3.75, cumulative cost = {inf}, id = 1071
LogicalProject(arrayStringNulls=[$0], uln=[$2], udn=[$3]): rowcount = 3.75, cumulative cost = {inf}, id = 1065
LogicalFilter(condition=[OR(=($2, 1), =($3, 2.2))]): rowcount = 3.75, cumulative cost = {inf}, id = 1064
LogicalCorrelate(correlation=[$cor1], joinType=[inner], requiredColumns=[{1}]): rowcount = 15.0, cumulative cost = {inf}, id = 1063
LogicalProject(arrayStringNulls=[$0], arrayDoubleNulls=[$2], uln=[$3]): rowcount = 15.0, cumulative cost = {inf}, id = 1059
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{1}]): rowcount = 15.0, cumulative cost = {inf}, id = 1058
LogicalProject(arrayStringNulls=[$1], arrayLongNulls=[$2], arrayDoubleNulls=[$3]): rowcount = 15.0, cumulative cost = {230.0 rows, 646.0 cpu, 0.0 io}, id = 1054
LogicalFilter(condition=[=($0, CAST(ARRAY('a', 'b')):VARCHAR ARRAY NOT NULL)]): rowcount = 15.0, cumulative cost = {215.0 rows, 601.0 cpu, 0.0 io}, id = 1053
LogicalProject(arrayString=[$1], arrayStringNulls=[$2], arrayLongNulls=[$4], arrayDoubleNulls=[$6]): rowcount = 100.0, cumulative cost = {200.0 rows, 501.0 cpu, 0.0 io}, id = 1052
LogicalTableScan(table=[[druid, arrays]]): rowcount = 100.0, cumulative cost = {100.0 rows, 101.0 cpu, 0.0 io}, id = 630
Uncollect: rowcount = 1.0, cumulative cost = {3.0 rows, 3.0 cpu, 0.0 io}, id = 1057
LogicalProject(arrayLongNulls=[$cor0.arrayLongNulls]): rowcount = 1.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 1056
LogicalValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 631
Uncollect: rowcount = 1.0, cumulative cost = {3.0 rows, 3.0 cpu, 0.0 io}, id = 1062
LogicalProject(arrayDoubleNulls=[$cor1.arrayDoubleNulls]): rowcount = 1.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 1061
LogicalValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 637
LogicalFilter(condition=[=($0, 'a')]): rowcount = 1.0, cumulative cost = {4.0 rows, 4.0 cpu, 0.0 io}, id = 1070
Uncollect: rowcount = 1.0, cumulative cost = {3.0 rows, 3.0 cpu, 0.0 io}, id = 1069
LogicalProject(arrayStringNulls=[$cor2.arrayStringNulls]): rowcount = 1.0, cumulative cost = {2.0 rows, 2.0 cpu, 0.0 io}, id = 1068
LogicalValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 643

View File

@ -281,23 +281,15 @@ public class CalciteRulesManager
{
final HepProgramBuilder builder = HepProgram.builder();
builder.addMatchLimit(CalciteRulesManager.HEP_DEFAULT_MATCH_LIMIT);
// builder.addGroupBegin();
builder.addRuleCollection(baseRuleSet(plannerContext));
builder.addRuleInstance(CoreRules.UNION_MERGE);
// builder.addGroupEnd();
builder.addRuleInstance(JoinExtractFilterRule.Config.DEFAULT.toRule());
builder.addRuleInstance(FilterIntoJoinRuleConfig.DEFAULT.withPredicate(DruidJoinRule::isSupportedPredicate).toRule());
// builder.addGroupBegin();
builder.addRuleInstance(FilterCorrelateRule.Config.DEFAULT.toRule());
builder.addRuleCollection(baseRuleSet(plannerContext));
builder.addRuleInstance(CoreRules.UNION_MERGE);
builder.addRuleInstance(FilterCorrelateRule.Config.DEFAULT.toRule());
builder.addRuleInstance(FilterProjectTransposeRule.Config.DEFAULT.toRule());
// builder.addGroupEnd();
builder.addRuleInstance(JoinExtractFilterRule.Config.DEFAULT.toRule());
builder.addRuleInstance(FilterIntoJoinRuleConfig.DEFAULT.withPredicate(DruidJoinRule::isSupportedPredicate).toRule());
final HepProgramBuilder builder2 = HepProgram.builder();
builder2.addRuleInstance(new LogicalUnnestRule());
builder2.addRuleInstance(new UnnestInputCleanupRule());
@ -305,15 +297,11 @@ public class CalciteRulesManager
builder2.addRuleInstance(CoreRules.PROJECT_MERGE);
builder2.addRuleInstance(AggregateProjectMergeRule.Config.DEFAULT.toRule());
return Programs.sequence(
new LoggingProgram("__decStart", true),
Programs.of(builder.build(), true, DefaultRelMetadataProvider.INSTANCE),
new LoggingProgram("__decAfterBuild1", true),
new DruidTrimFieldsProgram(false),
new LoggingProgram("__decAfterTrim1", true),
new DruidTrimFieldsProgram(true),
Programs.of(builder2.build(), true, DefaultRelMetadataProvider.INSTANCE),
new LoggingProgram("__decAfterBuild2", true),
new DruidTrimFieldsProgram(false),
new LoggingProgram("__decAfterTrim2", true)
Programs.of(builder2.build(), true, DefaultRelMetadataProvider.INSTANCE)
);
}
@ -569,7 +557,7 @@ public class CalciteRulesManager
{
final RelBuilder relBuilder = RelFactories.LOGICAL_BUILDER.create(rel.getCluster(), null);
final RelNode decorrelatedRel = RelDecorrelator.decorrelateQuery(rel, relBuilder);
return runFieldTrimmer(relBuilder, decorrelatedRel);
return runFieldTrimmer2(relBuilder, decorrelatedRel);
}
}