Search in sources :

Example 1 with RelWriter

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelWriter in project calcite by apache.

the class RelOptUtil method toString.

/**
 * 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();
}
Also used : StringWriter(java.io.StringWriter) RelWriterImpl(org.apache.calcite.rel.externalize.RelWriterImpl) RelWriter(org.apache.calcite.rel.RelWriter) PrintWriter(java.io.PrintWriter)

Example 2 with RelWriter

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelWriter in project hive by apache.

the class RelTreeSignature method relSignature.

private String relSignature(RelNode rel) {
    if (rel == null) {
        return null;
    }
    final StringWriter sw = new StringWriter();
    final RelWriter planWriter = new NonRecursiveRelWriterImpl(new PrintWriter(sw), SqlExplainLevel.EXPPLAN_ATTRIBUTES, false);
    rel.explain(planWriter);
    return sw.toString();
}
Also used : StringWriter(java.io.StringWriter) RelWriter(org.apache.calcite.rel.RelWriter) PrintWriter(java.io.PrintWriter)

Example 3 with RelWriter

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelWriter in project drill by axbaretto.

the class PrelSequencer method printWithIds.

public static String printWithIds(final Prel rel, SqlExplainLevel explainlevel) {
    if (rel == null) {
        return null;
    }
    final StringWriter sw = new StringWriter();
    final RelWriter planWriter = new NumberingRelWriter(getIdMap(rel), new PrintWriter(sw), explainlevel);
    rel.explain(planWriter);
    return sw.toString();
}
Also used : StringWriter(java.io.StringWriter) RelWriter(org.apache.calcite.rel.RelWriter) PrintWriter(java.io.PrintWriter)

Example 4 with RelWriter

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelWriter in project calcite by apache.

the class RelOptUtil method dumpPlan.

/**
 * Dumps a plan as a string.
 *
 * @param header      Header to print before the plan. Ignored if the format
 *                    is XML
 * @param rel         Relational expression to explain
 * @param format      Output format
 * @param detailLevel Detail level
 * @return Plan
 */
public static String dumpPlan(String header, RelNode rel, SqlExplainFormat format, SqlExplainLevel detailLevel) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    if (!header.equals("")) {
        pw.println(header);
    }
    RelWriter planWriter;
    switch(format) {
        case XML:
            planWriter = new RelXmlWriter(pw, detailLevel);
            break;
        case JSON:
            planWriter = new RelJsonWriter();
            rel.explain(planWriter);
            return ((RelJsonWriter) planWriter).asString();
        default:
            planWriter = new RelWriterImpl(pw, detailLevel, false);
    }
    rel.explain(planWriter);
    pw.flush();
    return sw.toString();
}
Also used : RelXmlWriter(org.apache.calcite.rel.externalize.RelXmlWriter) StringWriter(java.io.StringWriter) RelWriterImpl(org.apache.calcite.rel.externalize.RelWriterImpl) RelJsonWriter(org.apache.calcite.rel.externalize.RelJsonWriter) RelWriter(org.apache.calcite.rel.RelWriter) PrintWriter(java.io.PrintWriter)

Example 5 with RelWriter

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelWriter in project drill by apache.

the class PrelSequencer method printWithIds.

public static String printWithIds(final Prel rel, SqlExplainLevel explainlevel) {
    if (rel == null) {
        return null;
    }
    final StringWriter sw = new StringWriter();
    final RelWriter planWriter = new NumberingRelWriter(getIdMap(rel), new PrintWriter(sw), explainlevel);
    rel.explain(planWriter);
    return sw.toString();
}
Also used : StringWriter(java.io.StringWriter) RelWriter(org.apache.calcite.rel.RelWriter) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)5 StringWriter (java.io.StringWriter)5 RelWriter (org.apache.calcite.rel.RelWriter)5 RelWriterImpl (org.apache.calcite.rel.externalize.RelWriterImpl)2 RelJsonWriter (org.apache.calcite.rel.externalize.RelJsonWriter)1 RelXmlWriter (org.apache.calcite.rel.externalize.RelXmlWriter)1