Search in sources :

Example 1 with Capability

use of org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability in project teiid by teiid.

the class CapabilitiesConverter method setSupports.

private static void setSupports(Object connectorID, BasicSourceCapabilities tgtCaps, Capability cap, boolean supports, Capability... required) {
    if (!supports) {
        return;
    }
    for (Capability capability : required) {
        if (!tgtCaps.supportsCapability(capability)) {
            LogManager.logWarning(LogConstants.CTX_CONNECTOR, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30003, cap, capability, connectorID));
            supports = false;
        }
    }
    tgtCaps.setCapabilitySupport(cap, supports);
}
Also used : Capability(org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability)

Example 2 with Capability

use of org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability in project teiid by teiid.

the class CriteriaCapabilityValidatorVisitor method checkCompareCriteria.

public void checkCompareCriteria(AbstractCompareCriteria obj, Expression rightExpression) {
    boolean negated = false;
    // Check if operation is allowed
    Capability operatorCap = null;
    switch(obj.getOperator()) {
        case CompareCriteria.NE:
            negated = true;
        case CompareCriteria.EQ:
            operatorCap = Capability.CRITERIA_COMPARE_EQ;
            break;
        case CompareCriteria.LT:
        case CompareCriteria.GT:
            operatorCap = Capability.CRITERIA_COMPARE_ORDERED_EXCLUSIVE;
            break;
        case CompareCriteria.LE:
        case CompareCriteria.GE:
            operatorCap = Capability.CRITERIA_COMPARE_ORDERED;
            break;
    }
    // Check if compares are allowed
    if (!this.caps.supportsCapability(operatorCap)) {
        boolean unsupported = true;
        if (operatorCap == Capability.CRITERIA_COMPARE_ORDERED_EXCLUSIVE && this.caps.supportsCapability(Capability.CRITERIA_COMPARE_ORDERED) && this.caps.supportsCapability(Capability.CRITERIA_NOT)) {
            unsupported = false;
        }
        if (unsupported) {
            if (EvaluatableVisitor.willBecomeConstant(obj)) {
                return;
            }
            // $NON-NLS-1$
            markInvalid(obj, operatorCap + " CompareCriteria not supported by source");
            return;
        }
    }
    if (negated && !this.caps.supportsCapability(Capability.CRITERIA_NOT)) {
        if (EvaluatableVisitor.willBecomeConstant(obj)) {
            return;
        }
        // $NON-NLS-1$
        markInvalid(obj, "Negation is not supported by source");
        return;
    }
    // Check capabilities of the elements
    try {
        int support = SupportConstants.Element.SEARCHABLE_COMPARE;
        if (!negated && obj.getOperator() == CompareCriteria.EQ) {
            support = SupportConstants.Element.SEARCHABLE_EQUALITY;
        }
        checkElementsAreSearchable(obj.getLeftExpression(), support);
        checkElementsAreSearchable(rightExpression, support);
    } catch (QueryMetadataException e) {
        handleException(new TeiidComponentException(e));
    } catch (TeiidComponentException e) {
        handleException(e);
    }
}
Also used : Capability(org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability) TeiidComponentException(org.teiid.core.TeiidComponentException) QueryMetadataException(org.teiid.api.exception.query.QueryMetadataException)

Example 3 with Capability

use of org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability in project teiid by teiid.

the class CriteriaCapabilityValidatorVisitor method visit.

/**
 * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.SubqueryCompareCriteria)
 */
public void visit(SubqueryCompareCriteria crit) {
    if (crit.getArrayExpression() != null) {
        // $NON-NLS-1$
        markInvalid(crit, "Quantified compare with an array cannot yet be pushed down.");
        return;
    }
    // Check if quantification operator is allowed
    Capability capability = Capability.QUERY_SUBQUERIES_SCALAR;
    switch(crit.getPredicateQuantifier()) {
        case SubqueryCompareCriteria.ALL:
            capability = Capability.CRITERIA_QUANTIFIED_ALL;
            break;
        case SubqueryCompareCriteria.ANY:
            capability = Capability.CRITERIA_QUANTIFIED_SOME;
            break;
        case SubqueryCompareCriteria.SOME:
            capability = Capability.CRITERIA_QUANTIFIED_SOME;
            break;
    }
    if (!this.caps.supportsCapability(capability)) {
        // $NON-NLS-1$
        markInvalid(crit, "SubqueryCompare not supported by source");
        return;
    }
    checkCompareCriteria(crit, crit.getCommand().getProjectedSymbols().get(0));
    // Check capabilities of the elements
    try {
        if (validateSubqueryPushdown(crit, modelID, metadata, capFinder, analysisRecord) == null) {
            // $NON-NLS-1$
            markInvalid(crit.getCommand(), "Subquery cannot be pushed down");
        }
    } catch (QueryMetadataException e) {
        handleException(new TeiidComponentException(e));
    } catch (TeiidComponentException e) {
        handleException(e);
    }
}
Also used : Capability(org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability) TeiidComponentException(org.teiid.core.TeiidComponentException) QueryMetadataException(org.teiid.api.exception.query.QueryMetadataException)

Aggregations

Capability (org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability)3 QueryMetadataException (org.teiid.api.exception.query.QueryMetadataException)2 TeiidComponentException (org.teiid.core.TeiidComponentException)2