Search in sources :

Example 6 with SqlExplain

use of org.apache.calcite.sql.SqlExplain in project drill by apache.

the class ExplainHandler method rewrite.

@Override
public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
    SqlExplain node = unwrap(sqlNode, SqlExplain.class);
    SqlLiteral op = node.operand(2);
    SqlExplain.Depth depth = (SqlExplain.Depth) op.getValue();
    if (node.getDetailLevel() != null) {
        level = node.getDetailLevel();
    }
    switch(depth) {
        case LOGICAL:
            mode = ResultMode.LOGICAL;
            break;
        case PHYSICAL:
            mode = ResultMode.PHYSICAL;
            break;
        default:
            throw new UnsupportedOperationException("Unknown depth " + depth);
    }
    return node.operand(0);
}
Also used : SqlExplain(org.apache.calcite.sql.SqlExplain) SqlLiteral(org.apache.calcite.sql.SqlLiteral)

Aggregations

SqlExplain (org.apache.calcite.sql.SqlExplain)6 RelDataType (org.apache.calcite.rel.type.RelDataType)3 ImmutableList (com.google.common.collect.ImmutableList)2 AbstractList (java.util.AbstractList)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 RelRoot (org.apache.calcite.rel.RelRoot)2 SqlLiteral (org.apache.calcite.sql.SqlLiteral)2 SqlNodeList (org.apache.calcite.sql.SqlNodeList)2 ImmutableNullableList (org.apache.calcite.util.ImmutableNullableList)2 RelOptPlanner (org.apache.calcite.plan.RelOptPlanner)1 SqlExplainFormat (org.apache.calcite.sql.SqlExplainFormat)1 SqlExplainLevel (org.apache.calcite.sql.SqlExplainLevel)1 SqlNode (org.apache.calcite.sql.SqlNode)1 SqlParseException (org.apache.calcite.sql.parser.SqlParseException)1 SqlToRelConverter (org.apache.calcite.sql2rel.SqlToRelConverter)1 RelConversionException (org.apache.calcite.tools.RelConversionException)1 ValidationException (org.apache.calcite.tools.ValidationException)1 ImmutableIntList (org.apache.calcite.util.ImmutableIntList)1