Search in sources :

Example 1 with ValidationException

use of org.apache.iceberg.exceptions.ValidationException in project drill by apache.

the class IcebergPluginImplementor method canImplement.

@Override
public boolean canImplement(Filter filter) {
    RexNode condition = filter.getCondition();
    LogicalExpression logicalExpression = DrillOptiq.toDrill(new DrillParseContext(PrelUtil.getPlannerSettings(filter.getCluster().getPlanner())), filter.getInput(), condition);
    Expression expression = logicalExpression.accept(DrillExprToIcebergTranslator.INSTANCE, null);
    if (expression != null) {
        try {
            GroupScan scan = findGroupScan(filter);
            if (scan instanceof IcebergGroupScan) {
                IcebergGroupScan groupScan = (IcebergGroupScan) scan;
                // ensures that expression compatible with table schema
                expression = Binder.bind(groupScan.getTableScan().schema().asStruct(), expression, true);
            } else {
                return false;
            }
        } catch (ValidationException e) {
            return false;
        }
    }
    return expression != null;
}
Also used : IcebergGroupScan(org.apache.drill.exec.store.iceberg.IcebergGroupScan) GroupScan(org.apache.drill.exec.physical.base.GroupScan) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) ValidationException(org.apache.iceberg.exceptions.ValidationException) Expression(org.apache.iceberg.expressions.Expression) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) DrillParseContext(org.apache.drill.exec.planner.logical.DrillParseContext) IcebergGroupScan(org.apache.drill.exec.store.iceberg.IcebergGroupScan) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

RexNode (org.apache.calcite.rex.RexNode)1 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)1 GroupScan (org.apache.drill.exec.physical.base.GroupScan)1 DrillParseContext (org.apache.drill.exec.planner.logical.DrillParseContext)1 IcebergGroupScan (org.apache.drill.exec.store.iceberg.IcebergGroupScan)1 ValidationException (org.apache.iceberg.exceptions.ValidationException)1 Expression (org.apache.iceberg.expressions.Expression)1