org.apache.calcite.rel.RelWriter Java Examples
The following examples show how to use
org.apache.calcite.rel.RelWriter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrelSequencer.java From dremio-oss with Apache License 2.0 | 7 votes |
/** * Generate readable text and json plans and set them in <code>planHolder</code> * @param rel * @param explainlevel explain plan level. * @param observer */ public static String setPlansWithIds(final Prel rel, final SqlExplainLevel explainlevel, final AttemptObserver observer, final long millisTaken) { if (rel == null) { return null; } Map<Prel, OpId> relIdMap = getIdMap(rel); final StringWriter sw = new StringWriter(); final RelWriter textPlanWriter = new NumberingRelWriter(relIdMap, new PrintWriter(sw), explainlevel); rel.explain(textPlanWriter); final String textPlan = sw.toString(); observer.planText(sw.toString(), millisTaken); final RelJsonWriter jsonPlanWriter = new RelJsonWriter(getIdMap(rel), explainlevel); rel.explain(jsonPlanWriter); observer.planJsonPlan(jsonPlanWriter.asString()); return textPlan; }
Example #2
Source File: NumberingRelWriter.java From Bats with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") public RelWriter done(RelNode node) { int i = 0; if (values.size() > 0 && values.get(0).left.equals("subset")) { ++i; } for (RelNode input : node.getInputs()) { assert values.get(i).right == input; ++i; } for (RexNode expr : node.getChildExps()) { assert values.get(i).right == expr; ++i; } final List<Pair<String, Object>> valuesCopy = ImmutableList.copyOf(values); values.clear(); explain_(node, valuesCopy); pw.flush(); return this; }
Example #3
Source File: ScanRelBase.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override public RelWriter explainTerms(RelWriter pw) { pw.item("table", tableMetadata.getName()); if(projectedColumns != null){ pw.item("columns", FluentIterable.from(projectedColumns).transform(new Function<SchemaPath, String>(){ @Override public String apply(SchemaPath input) { return input.toString(); }}).join(Joiner.on(", "))); } pw.item("splits", getTableMetadata().getSplitCount()); if(observedRowcountAdjustment != 1.0d){ pw.item("rowAdjust", observedRowcountAdjustment); } // we need to include the table metadata digest since not all properties (specifically which splits) are included in the explain output (what base computeDigest uses). pw.itemIf("tableDigest", tableMetadata.computeDigest(), pw.getDetailLevel() == SqlExplainLevel.DIGEST_ATTRIBUTES); return pw; }
Example #4
Source File: Sort.java From calcite with Apache License 2.0 | 6 votes |
public RelWriter explainTerms(RelWriter pw) { super.explainTerms(pw); assert fieldExps.size() == collation.getFieldCollations().size(); if (pw.nest()) { pw.item("collation", collation); } else { for (Ord<RexNode> ord : Ord.zip(fieldExps)) { pw.item("sort" + ord.i, ord.e); } for (Ord<RelFieldCollation> ord : Ord.zip(collation.getFieldCollations())) { pw.item("dir" + ord.i, ord.e.shortString()); } } pw.itemIf("offset", offset, offset != null); pw.itemIf("fetch", fetch, fetch != null); return pw; }
Example #5
Source File: NumberingRelWriter.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override public RelWriter done(RelNode node) { int i = 0; if (values.size() > 0 && values.get(0).left.equals("subset")) { ++i; } for (RelNode input : node.getInputs()) { assert values.get(i).right == input; ++i; } for (RexNode expr : node.getChildExps()) { assert values.get(i).right == expr; ++i; } final List<Pair<String, Object>> valuesCopy = ImmutableList.copyOf(values); values.clear(); explain_(node, valuesCopy); pw.flush(); return this; }
Example #6
Source File: NumberingRelWriter.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public RelWriter itemIf(String term, Object value, boolean condition) { if (condition) { item(term, value); } return this; }
Example #7
Source File: AbstractConverter.java From calcite with Apache License 2.0 | 5 votes |
public RelWriter explainTerms(RelWriter pw) { super.explainTerms(pw); for (RelTrait trait : traitSet) { pw.item(trait.getTraitDef().getSimpleName(), trait); } return pw; }
Example #8
Source File: TableModify.java From calcite with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { return super.explainTerms(pw) .item("table", table.getQualifiedName()) .item("operation", RelEnumTypes.fromEnum(getOperation())) .itemIf("updateColumnList", updateColumnList, updateColumnList != null) .itemIf("sourceExpressionList", sourceExpressionList, sourceExpressionList != null) .item("flattened", flattened); }
Example #9
Source File: RelSubset.java From calcite with Apache License 2.0 | 5 votes |
@Override public void explain(RelWriter pw) { // Not a typical implementation of "explain". We don't gather terms & // values to be printed later. We actually do the work. pw.item("subset", toString()); final AbstractRelNode input = (AbstractRelNode) Util.first(getBest(), getOriginal()); if (input == null) { return; } input.explainTerms(pw); pw.done(input); }
Example #10
Source File: RelOptUtil.java From Bats with Apache License 2.0 | 5 votes |
/** * Converts a relational expression to a string. */ public static String toString(final RelNode rel, SqlExplainLevel detailLevel) { if (rel == null) { return null; } final StringWriter sw = new StringWriter(); final RelWriter planWriter = new RelWriterImpl(new PrintWriter(sw), detailLevel, false); rel.explain(planWriter); return sw.toString(); }
Example #11
Source File: ValuesPrel.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { if (content.isOpaque()) { return super.explainTerms(pw).item("Key", content.hashCode()); } else { return super.explainTerms(pw).item("Values", content.asNode()); } }
Example #12
Source File: MultiJoin.java From calcite with Apache License 2.0 | 5 votes |
public RelWriter explainTerms(RelWriter pw) { List<String> joinTypeNames = new ArrayList<>(); List<String> outerJoinConds = new ArrayList<>(); List<String> projFieldObjects = new ArrayList<>(); for (int i = 0; i < inputs.size(); i++) { joinTypeNames.add(joinTypes.get(i).name()); if (outerJoinConditions.get(i) == null) { outerJoinConds.add("NULL"); } else { outerJoinConds.add(outerJoinConditions.get(i).toString()); } if (projFields.get(i) == null) { projFieldObjects.add("ALL"); } else { projFieldObjects.add(projFields.get(i).toString()); } } super.explainTerms(pw); for (Ord<RelNode> ord : Ord.zip(inputs)) { pw.input("input#" + ord.i, ord.e); } return pw.item("joinFilter", joinFilter) .item("isFullOuterJoin", isFullOuterJoin) .item("joinTypes", joinTypeNames) .item("outerJoinConditions", outerJoinConds) .item("projFields", projFieldObjects) .itemIf("postJoinFilter", postJoinFilter, postJoinFilter != null); }
Example #13
Source File: SplunkTableScan.java From calcite with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { return super.explainTerms(pw) .item("table", table.getQualifiedName()) .item("earliest", earliest) .item("latest", latest) .item("fieldList", fieldList); }
Example #14
Source File: SetOp.java From Bats with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { super.explainTerms(pw); for (Ord<RelNode> ord : Ord.zip(inputs)) { pw.input("input#" + ord.i, ord.e); } return pw.item("all", all); }
Example #15
Source File: MultiJoin.java From Bats with Apache License 2.0 | 5 votes |
public RelWriter explainTerms(RelWriter pw) { List<String> joinTypeNames = new ArrayList<>(); List<String> outerJoinConds = new ArrayList<>(); List<String> projFieldObjects = new ArrayList<>(); for (int i = 0; i < inputs.size(); i++) { joinTypeNames.add(joinTypes.get(i).name()); if (outerJoinConditions.get(i) == null) { outerJoinConds.add("NULL"); } else { outerJoinConds.add(outerJoinConditions.get(i).toString()); } if (projFields.get(i) == null) { projFieldObjects.add("ALL"); } else { projFieldObjects.add(projFields.get(i).toString()); } } super.explainTerms(pw); for (Ord<RelNode> ord : Ord.zip(inputs)) { pw.input("input#" + ord.i, ord.e); } return pw.item("joinFilter", joinFilter) .item("isFullOuterJoin", isFullOuterJoin) .item("joinTypes", joinTypeNames) .item("outerJoinConditions", outerJoinConds) .item("projFields", projFieldObjects) .itemIf("postJoinFilter", postJoinFilter, postJoinFilter != null); }
Example #16
Source File: RelJsonWriter.java From calcite with Apache License 2.0 | 5 votes |
public RelWriter done(RelNode node) { final List<Pair<String, Object>> valuesCopy = ImmutableList.copyOf(values); values.clear(); explain_(node, valuesCopy); return this; }
Example #17
Source File: Aggregate.java From calcite with Apache License 2.0 | 5 votes |
public RelWriter explainTerms(RelWriter pw) { // We skip the "groups" element if it is a singleton of "group". super.explainTerms(pw) .item("group", groupSet) .itemIf("groups", groupSets, getGroupType() != Group.SIMPLE) .itemIf("aggs", aggCalls, pw.nest()); if (!pw.nest()) { for (Ord<AggregateCall> ord : Ord.zip(aggCalls)) { pw.item(Util.first(ord.e.name, "agg#" + ord.i), ord.e); } } return pw; }
Example #18
Source File: OrderedMuxExchangePrel.java From Bats with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { super.explainTerms(pw); for (Ord<RelFieldCollation> ord : Ord.zip(this.fieldCollation.getFieldCollations())) { pw.item("sort" + ord.i, ord.e); } return pw; }
Example #19
Source File: DrillLimitRelBase.java From Bats with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { super.explainTerms(pw); pw.itemIf("offset", offset, offset != null); pw.itemIf("fetch", fetch, fetch != null); return pw; }
Example #20
Source File: RelJsonWriter.java From Bats with Apache License 2.0 | 5 votes |
public RelWriter done(RelNode node) { final List<Pair<String, Object>> valuesCopy = ImmutableList.copyOf(values); values.clear(); explain_(node, valuesCopy); return this; }
Example #21
Source File: RelDescriptionWriterImpl.java From flink with Apache License 2.0 | 5 votes |
@Override public RelWriter done(RelNode node) { final List<Pair<String, Object>> valuesCopy = ImmutableList.copyOf(values); values.clear(); explain(node, valuesCopy); pw.flush(); return this; }
Example #22
Source File: RexProgram.java From calcite with Apache License 2.0 | 5 votes |
/** * Writes an explanation of the expressions in this program to a plan * writer. * * @param pw Plan writer */ public RelWriter explainCalc(RelWriter pw) { if (pw instanceof RelJsonWriter) { return pw .item("exprs", exprs) .item("projects", projects) .item("condition", condition) .item("inputRowType", inputRowType) .item("outputRowType", outputRowType); } else { return collectExplainTerms("", pw, pw.getDetailLevel()); } }
Example #23
Source File: OLAPWindowRel.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { return super.explainTerms(pw) .item("ctx", context == null ? "" : String.valueOf(context.id) + "@" + context.realization)// .itemIf("constants", constants, !constants.isEmpty()) // .itemIf("groups", groups, !groups.isEmpty()); }
Example #24
Source File: OLAPTableScan.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { return super.explainTerms(pw) .item("ctx", context == null ? "" : String.valueOf(context.id) + "@" + context.realization) .item("fields", Primitive.asList(fields)); }
Example #25
Source File: ValuesRel.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { return super.explainTerms(pw) .itemIf("type", this.rowType, pw.getDetailLevel() == SqlExplainLevel.DIGEST_ATTRIBUTES) .itemIf("type", this.rowType.getFieldList(), pw.nest()) .itemIf("tuplesCount", rowCount, pw.getDetailLevel() != SqlExplainLevel.ALL_ATTRIBUTES) .itemIf("tuples", options.asNode(), pw.getDetailLevel() == SqlExplainLevel.DIGEST_ATTRIBUTES); }
Example #26
Source File: ParquetScanPrel.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { pw = super.explainTerms(pw); if(filter != null){ return pw.item("filters", filter); } return pw; }
Example #27
Source File: NestedLoopJoinPrel.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { boolean projectAll = projectedFields == null || projectedFields.cardinality() == left.getRowType().getFieldCount() + right.getRowType().getFieldCount(); return super.explainTerms(pw) .itemIf("vectorCondition", vectorExpression, vectorExpression != null) .itemIf("projectedFields", projectedFields, !projectAll); }
Example #28
Source File: SingleMergeExchangePrel.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public RelWriter explainTerms(RelWriter pw) { super.explainTerms(pw); if (pw.nest()) { pw.item("collation", collation); } else { for (Ord<RelFieldCollation> ord : Ord.zip(collation.getFieldCollations())) { pw.item("sort" + ord.i, ord.e); } } return pw; }
Example #29
Source File: RelJsonWriter.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public RelWriter itemIf(String term, Object value, boolean condition) { if (condition) { item(term, value); } return this; }
Example #30
Source File: RelJsonWriter.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public RelWriter done(RelNode node) { final List<Pair<String, Object>> valuesCopy = ImmutableList.copyOf(values); values.clear(); explain_(node, valuesCopy); return this; }