本文整理了Java中org.apache.calcite.plan.RelOptUtil.toString
方法的一些代码示例,展示了RelOptUtil.toString
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RelOptUtil.toString
方法的具体详情如下:
包路径:org.apache.calcite.plan.RelOptUtil
类名称:RelOptUtil
方法名:toString
[英]Converts a relational expression to a string, showing just basic attributes.
[中]将关系表达式转换为字符串,只显示基本属性。
代码示例来源:origin: apache/storm
public static String explain(final RelNode rel, SqlExplainLevel detailLevel) {
String explain = "";
try {
explain = RelOptUtil.toString(rel);
} catch (StackOverflowError e) {
LOG.error("StackOverflowError occurred while extracting plan. Please report it to the dev@ mailing list.");
LOG.error("RelNode " + rel + " ExplainLevel " + detailLevel, e);
LOG.error("Forcing plan to empty string and continue... SQL Runner may not working properly after.");
}
return explain;
}
}
代码示例来源:origin: apache/hive
@Override
public Double getRowCount(SemiJoin rel, RelMetadataQuery mq) {
PKFKRelationInfo pkfk = analyzeJoinForPKFK(rel, mq);
if (pkfk != null) {
double selectivity = pkfk.pkInfo.selectivity * pkfk.ndvScalingFactor;
selectivity = Math.min(1.0, selectivity);
if (LOG.isDebugEnabled()) {
LOG.debug("Identified Primary - Foreign Key relation: {} {}", RelOptUtil.toString(rel), pkfk);
}
return pkfk.fkInfo.rowCount * selectivity;
}
return super.getRowCount(rel, mq);
}
代码示例来源:origin: apache/drill
@Override
public Double getRowCount(SemiJoin rel, RelMetadataQuery mq) {
PKFKRelationInfo pkfk = analyzeJoinForPKFK(rel, mq);
if (pkfk != null) {
double selectivity = (pkfk.pkInfo.selectivity * pkfk.ndvScalingFactor);
selectivity = Math.min(1.0, selectivity);
if (LOG.isDebugEnabled()) {
LOG.debug("Identified Primary - Foreign Key relation: {} {}", RelOptUtil.toString(rel), pkfk);
}
return pkfk.fkInfo.rowCount * selectivity;
}
return super.getRowCount(rel, mq);
}
代码示例来源:origin: apache/drill
public Double getRowCount(Join join, RelMetadataQuery mq) {
PKFKRelationInfo pkfk = analyzeJoinForPKFK(join, mq);
if (pkfk != null) {
double selectivity = (pkfk.pkInfo.selectivity * pkfk.ndvScalingFactor);
selectivity = Math.min(1.0, selectivity);
if (LOG.isDebugEnabled()) {
LOG.debug("Identified Primary - Foreign Key relation: {} {}",RelOptUtil.toString(join), pkfk);
}
return pkfk.fkInfo.rowCount * selectivity;
}
return join.getRows();
}
代码示例来源:origin: apache/hive
" Join selectivity: {}\n Residual selectivity: {}\n", RelOptUtil.toString(join), constraintBasedResult.left,
rowCount, joinSelectivity, residualSelectivity);
selectivity = Math.min(1.0, selectivity);
if (LOG.isDebugEnabled()) {
LOG.debug("Identified Primary - Foreign Key relation: {} {}", RelOptUtil.toString(join), pkfk);
if (LOG.isDebugEnabled()) {
LOG.debug("No Primary - Foreign Key relation: \n{} Row count for join: {}\n",
RelOptUtil.toString(join), rowCount);
代码示例来源:origin: apache/hive
RelNode newTopNode = rel;
if (LOG.isDebugEnabled()) {
LOG.debug("Original plan for PlanModifier\n " + RelOptUtil.toString(newTopNode));
if (LOG.isDebugEnabled()) {
LOG.debug("Plan after top-level introduceDerivedTable\n "
+ RelOptUtil.toString(newTopNode));
LOG.debug("Plan after nested convertOpTree\n " + RelOptUtil.toString(newTopNode));
newTopNode = propagator.align(newTopNode);
if (LOG.isDebugEnabled()) {
LOG.debug("Plan after propagating order\n " + RelOptUtil.toString(newTopNode));
PlanModifierUtil.fixTopOBSchema(newTopNode, topSelparentPair, resultSchema, true);
if (LOG.isDebugEnabled()) {
LOG.debug("Plan after fixTopOBSchema\n " + RelOptUtil.toString(newTopNode));
newTopNode = renameTopLevelSelectInResultSchema(newTopNode, topSelparentPair, resultSchema);
if (LOG.isDebugEnabled()) {
LOG.debug("Final plan after modifier\n " + RelOptUtil.toString(newTopNode));
代码示例来源:origin: apache/drill
RelNode newTopNode = rel;
if (LOG.isDebugEnabled()) {
LOG.debug("Original plan for PlanModifier\n " + RelOptUtil.toString(newTopNode));
if (LOG.isDebugEnabled()) {
LOG.debug("Plan after top-level introduceDerivedTable\n "
+ RelOptUtil.toString(newTopNode));
LOG.debug("Plan after nested convertOpTree\n " + RelOptUtil.toString(newTopNode));
newTopNode = propagator.align(newTopNode);
if (LOG.isDebugEnabled()) {
LOG.debug("Plan after propagating order\n " + RelOptUtil.toString(newTopNode));
PlanModifierUtil.fixTopOBSchema(newTopNode, topSelparentPair, resultSchema, true);
if (LOG.isDebugEnabled()) {
LOG.debug("Plan after fixTopOBSchema\n " + RelOptUtil.toString(newTopNode));
newTopNode = renameTopLevelSelectInResultSchema(newTopNode, topSelparentPair, resultSchema);
if (LOG.isDebugEnabled()) {
LOG.debug("Final plan after modifier\n " + RelOptUtil.toString(newTopNode));
代码示例来源:origin: apache/hive
public RelOptCost getJoinCost(HiveJoin join) {
// Select algorithm with min cost
JoinAlgorithm joinAlgorithm = null;
RelOptCost minJoinCost = null;
if (LOG.isTraceEnabled()) {
LOG.trace("Join algorithm selection for:\n" + RelOptUtil.toString(join));
}
for (JoinAlgorithm possibleAlgorithm : this.joinAlgorithms) {
if (!possibleAlgorithm.isExecutable(join)) {
continue;
}
RelOptCost joinCost = possibleAlgorithm.getCost(join);
if (LOG.isTraceEnabled()) {
LOG.trace(possibleAlgorithm + " cost: " + joinCost);
}
if (minJoinCost == null || joinCost.isLt(minJoinCost) ) {
joinAlgorithm = possibleAlgorithm;
minJoinCost = joinCost;
}
}
if (LOG.isTraceEnabled()) {
LOG.trace(joinAlgorithm + " selected");
}
join.setJoinAlgorithm(joinAlgorithm);
join.setJoinCost(minJoinCost);
return minJoinCost;
}
代码示例来源:origin: apache/drill
public RelOptCost getJoinCost(HiveJoin join) {
// Select algorithm with min cost
JoinAlgorithm joinAlgorithm = null;
RelOptCost minJoinCost = null;
if (LOG.isTraceEnabled()) {
LOG.trace("Join algorithm selection for:\n" + RelOptUtil.toString(join));
}
for (JoinAlgorithm possibleAlgorithm : this.joinAlgorithms) {
if (!possibleAlgorithm.isExecutable(join)) {
continue;
}
RelOptCost joinCost = possibleAlgorithm.getCost(join);
if (LOG.isTraceEnabled()) {
LOG.trace(possibleAlgorithm + " cost: " + joinCost);
}
if (minJoinCost == null || joinCost.isLt(minJoinCost) ) {
joinAlgorithm = possibleAlgorithm;
minJoinCost = joinCost;
}
}
if (LOG.isTraceEnabled()) {
LOG.trace(joinAlgorithm + " selected");
}
join.setJoinAlgorithm(joinAlgorithm);
join.setJoinCost(minJoinCost);
return minJoinCost;
}
代码示例来源:origin: apache/hive
LOG.debug("Plan before removing subquery:\n" + RelOptUtil.toString(calciteGenPlan));
calciteGenPlan = hepPlan(calciteGenPlan, false, mdProvider.getMetadataProvider(), null,
new HiveSubQueryRemoveRule(conf));
LOG.debug("Plan just after removing subquery:\n" + RelOptUtil.toString(calciteGenPlan));
LOG.debug("Plan after decorrelation:\n" + RelOptUtil.toString(calciteGenPlan));
LOG.debug("Original Plan:\n" + RelOptUtil.toString(calciteGenPlan));
LOG.debug("Plan After PPD, PartPruning, ColumnPruning:\n"
+ RelOptUtil.toString(calcitePreCboPlan));
LOG.debug("Plan After Join Reordering:\n"
+ RelOptUtil.toString(calciteOptimizedPlan, SqlExplainLevel.ALL_ATTRIBUTES));
代码示例来源:origin: apache/hive
@Test
public void testIsNull_one() {
// @formatter:off
final RelNode basePlan = builder
.scan("t")
.filter(
builder.call(SqlStdOperatorTable.IS_NULL,
builder.field("_str")
)
)
.build();
// @formatter:on
statObj.setNumNulls(1);
planner.setRoot(basePlan);
System.out.println(RelOptUtil.toString(basePlan));
RelNode optimizedRelNode = planner.findBestExp();
System.out.println(RelOptUtil.toString(optimizedRelNode));
assertNotEquals("should not be a literal", SqlKind.LITERAL, optimizedRelNode.getChildExps().get(0).getKind());
}
代码示例来源:origin: apache/drill
LOG.debug("Plan before removing subquery:\n" + RelOptUtil.toString(calciteGenPlan));
calciteGenPlan = hepPlan(calciteGenPlan, false, mdProvider.getMetadataProvider(), null,
HiveSubQueryRemoveRule.FILTER, HiveSubQueryRemoveRule.PROJECT);
LOG.debug("Plan just after removing subquery:\n" + RelOptUtil.toString(calciteGenPlan));
LOG.debug("Plan after decorrelation:\n" + RelOptUtil.toString(calciteGenPlan));
LOG.debug("Original Plan:\n" + RelOptUtil.toString(calciteGenPlan));
LOG.debug("Plan After PPD, PartPruning, ColumnPruning:\n"
+ RelOptUtil.toString(calcitePreCboPlan));
LOG.debug("Plan After Join Reordering:\n"
+ RelOptUtil.toString(calciteOptimizedPlan, SqlExplainLevel.ALL_ATTRIBUTES));
代码示例来源:origin: apache/hive
if (!RelOptUtil.toString(calcitePreMVRewritingPlan).equals(RelOptUtil.toString(basePlan))) {
代码示例来源:origin: apache/hive
@Test
public void testIsNull_all() {
// @formatter:off
final RelNode basePlan = builder
.scan("t")
.filter(
builder.call(SqlStdOperatorTable.IS_NULL,
builder.field("_str")
)
)
.build();
// @formatter:on
statObj.setNumNulls(3);
planner.setRoot(basePlan);
System.out.println(RelOptUtil.toString(basePlan));
RelNode optimizedRelNode = planner.findBestExp();
System.out.println(RelOptUtil.toString(optimizedRelNode));
assertEquals("missing literal", SqlKind.LITERAL, optimizedRelNode.getChildExps().get(0).getKind());
RexLiteral val = (RexLiteral) optimizedRelNode.getChildExps().get(0);
assertEquals(true, val.getValue());
}
代码示例来源:origin: apache/hive
@Test
public void testIsNotNull() {
// @formatter:off
final RelNode basePlan = builder
.scan("t")
.filter(
builder.call(SqlStdOperatorTable.IS_NOT_NULL,
builder.field("_str")
)
)
.build();
// @formatter:on
statObj.setNumNulls(0);
planner.setRoot(basePlan);
System.out.println(RelOptUtil.toString(basePlan));
RelNode optimizedRelNode = planner.findBestExp();
System.out.println(RelOptUtil.toString(optimizedRelNode));
assertEquals("missing literal", SqlKind.LITERAL, optimizedRelNode.getChildExps().get(0).getKind());
RexLiteral val = (RexLiteral) optimizedRelNode.getChildExps().get(0);
assertEquals(true, val.getValue());
}
代码示例来源:origin: apache/hive
@Test
public void testIsNull_zero() {
// @formatter:off
final RelNode basePlan = builder
.scan("t")
.filter(
builder.call(SqlStdOperatorTable.IS_NULL,
builder.field("_str")
)
)
.build();
// @formatter:on
statObj.setNumNulls(0);
planner.setRoot(basePlan);
System.out.println(RelOptUtil.toString(basePlan));
RelNode optimizedRelNode = planner.findBestExp();
System.out.println(RelOptUtil.toString(optimizedRelNode));
assertEquals("missing literal", SqlKind.LITERAL, optimizedRelNode.getChildExps().get(0).getKind());
RexLiteral val = (RexLiteral) optimizedRelNode.getChildExps().get(0);
assertEquals(false, val.getValue());
}
代码示例来源:origin: apache/hive
optimizedOptiqPlan, resultSchema, this.getQB().getTableDesc() != null);
LOG.debug("Translating the following plan:\n" + RelOptUtil.toString(modifiedOptimizedOptiqPlan));
Operator<?> hiveRoot = new HiveOpConverter(this, conf, unparseTranslator, topOps)
.convert(modifiedOptimizedOptiqPlan);
代码示例来源:origin: apache/drill
optimizedOptiqPlan, resultSchema, this.getQB().getTableDesc() != null);
LOG.debug("Translating the following plan:\n" + RelOptUtil.toString(modifiedOptimizedOptiqPlan));
Operator<?> hiveRoot = new HiveOpConverter(this, conf, unparseTranslator, topOps)
.convert(modifiedOptimizedOptiqPlan);
代码示例来源:origin: apache/hive
if (explainConfig.isCboExtended()) {
this.ctx.setCalcitePlan(RelOptUtil.toString(newPlan, SqlExplainLevel.ALL_ATTRIBUTES));
} else {
this.ctx.setCalcitePlan(RelOptUtil.toString(newPlan));
代码示例来源:origin: org.apache.calcite/calcite-core
/**
* Converts a relational expression to a string, showing just basic
* attributes.
*/
public static String toString(final RelNode rel) {
return toString(rel, SqlExplainLevel.EXPPLAN_ATTRIBUTES);
}
内容来源于网络,如有侵权,请联系作者删除!