Search in sources :

Example 1 with TypedSqlNode

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

the class DefaultSqlHandler method validateAndConvert.

protected ConvertedRelNode validateAndConvert(SqlNode sqlNode) throws ForemanSetupException, RelConversionException, ValidationException {
    final SqlNode rewrittenSqlNode = rewrite(sqlNode);
    final TypedSqlNode validatedTypedSqlNode = validateNode(rewrittenSqlNode);
    final SqlNode validated = validatedTypedSqlNode.getSqlNode();
    RelNode rel = convertToRel(validated);
    rel = preprocessNode(rel);
    return new ConvertedRelNode(rel, validatedTypedSqlNode.getType());
}
Also used : RelNode(org.apache.calcite.rel.RelNode) SqlNode(org.apache.calcite.sql.SqlNode) TypedSqlNode(org.apache.calcite.sql.TypedSqlNode) TypedSqlNode(org.apache.calcite.sql.TypedSqlNode)

Example 2 with TypedSqlNode

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

the class DefaultSqlHandler method validateNode.

private TypedSqlNode validateNode(SqlNode sqlNode) throws ValidationException, RelConversionException, ForemanSetupException {
    final SqlNode sqlNodeValidated = config.getConverter().validate(sqlNode);
    final TypedSqlNode typedSqlNode = new TypedSqlNode(sqlNodeValidated, config.getConverter().getOutputType(sqlNodeValidated));
    // Check if the unsupported functionality is used
    UnsupportedOperatorsVisitor visitor = UnsupportedOperatorsVisitor.createVisitor(context);
    try {
        sqlNodeValidated.accept(visitor);
    } catch (UnsupportedOperationException ex) {
        // If the exception due to the unsupported functionalities
        visitor.convertException();
        // If it is not, let this exception move forward to higher logic
        throw ex;
    }
    return typedSqlNode;
}
Also used : UnsupportedOperatorsVisitor(org.apache.drill.exec.planner.sql.parser.UnsupportedOperatorsVisitor) SqlNode(org.apache.calcite.sql.SqlNode) TypedSqlNode(org.apache.calcite.sql.TypedSqlNode) TypedSqlNode(org.apache.calcite.sql.TypedSqlNode)

Aggregations

SqlNode (org.apache.calcite.sql.SqlNode)2 TypedSqlNode (org.apache.calcite.sql.TypedSqlNode)2 RelNode (org.apache.calcite.rel.RelNode)1 UnsupportedOperatorsVisitor (org.apache.drill.exec.planner.sql.parser.UnsupportedOperatorsVisitor)1