Search in sources :

Example 1 with MakeDep

use of org.teiid.query.sql.lang.Option.MakeDep in project teiid by teiid.

the class SQLStringVisitor method addMakeDep.

private void addMakeDep(FromClause obj) {
    MakeDep makeDep = obj.getMakeDep();
    if (makeDep != null && !makeDep.isSimple()) {
        append(SPACE);
        append(MAKEDEP);
        appendMakeDepOptions(makeDep);
    }
    makeDep = obj.getMakeInd();
    if (makeDep != null && !makeDep.isSimple()) {
        append(SPACE);
        append(MAKEIND);
        appendMakeDepOptions(makeDep);
    }
}
Also used : MakeDep(org.teiid.query.sql.lang.Option.MakeDep)

Example 2 with MakeDep

use of org.teiid.query.sql.lang.Option.MakeDep in project teiid by teiid.

the class RuleChooseDependent method markDependent.

/**
 * Mark the specified access node to be made dependent
 * @param sourceNode Node to make dependent
 * @param dca
 * @param rules
 * @param analysisRecord
 * @param commandContext
 * @param capFinder
 * @throws TeiidComponentException
 * @throws QueryMetadataException
 * @throws QueryPlannerException
 */
boolean markDependent(PlanNode sourceNode, PlanNode joinNode, QueryMetadataInterface metadata, DependentCostAnalysis dca, Boolean bound, CapabilitiesFinder capabilitiesFinder, CommandContext context, RuleStack rules, AnalysisRecord analysisRecord) throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
    boolean isLeft = joinNode.getFirstChild() == sourceNode;
    // Get new access join node properties based on join criteria
    List independentExpressions = (List) (isLeft ? joinNode.getProperty(NodeConstants.Info.RIGHT_EXPRESSIONS) : joinNode.getProperty(NodeConstants.Info.LEFT_EXPRESSIONS));
    List dependentExpressions = (List) (isLeft ? joinNode.getProperty(NodeConstants.Info.LEFT_EXPRESSIONS) : joinNode.getProperty(NodeConstants.Info.RIGHT_EXPRESSIONS));
    if (independentExpressions == null || independentExpressions.isEmpty()) {
        return false;
    }
    PlanNode indNode = isLeft ? joinNode.getLastChild() : joinNode.getFirstChild();
    if (bound == null) {
        List<PlanNode> sources = NodeEditor.findAllNodes(indNode, NodeConstants.Types.SOURCE);
        for (PlanNode planNode : sources) {
            for (GroupSymbol gs : planNode.getGroups()) {
                if (gs.isTempTable() && metadata.getCardinality(gs.getMetadataID()) == QueryMetadataInterface.UNKNOWN_CARDINALITY) {
                    bound = true;
                    break;
                }
            }
        }
        if (bound == null) {
            bound = false;
        }
    }
    MakeDep makeDep = (MakeDep) sourceNode.getProperty(Info.MAKE_DEP);
    if (fullPushOnly) {
        fullyPush(sourceNode, joinNode, metadata, capabilitiesFinder, context, indNode, rules, makeDep, analysisRecord, independentExpressions);
        return false;
    }
    // Check that for a outer join the dependent side must be the inner
    JoinType jtype = (JoinType) joinNode.getProperty(NodeConstants.Info.JOIN_TYPE);
    if (jtype == JoinType.JOIN_FULL_OUTER || (jtype.isOuter() && JoinUtil.getInnerSideJoinNodes(joinNode)[0] != sourceNode)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        sourceNode.recordDebugAnnotation("node is on outer side of the join", null, "Rejecting dependent join", analysisRecord, null);
        return false;
    }
    String id = nextId();
    // Create DependentValueSource and set on the independent side as this will feed the values
    joinNode.setProperty(NodeConstants.Info.DEPENDENT_VALUE_SOURCE, id);
    PlanNode depNode = isLeft ? joinNode.getFirstChild() : joinNode.getLastChild();
    depNode = FrameUtil.findJoinSourceNode(depNode);
    if (!depNode.hasCollectionProperty(Info.ACCESS_PATTERNS)) {
        // in some situations a federated join will span multiple tables using the same key
        handleDuplicate(joinNode, isLeft, independentExpressions, dependentExpressions);
        handleDuplicate(joinNode, !isLeft, dependentExpressions, independentExpressions);
    }
    PlanNode crit = getDependentCriteriaNode(id, independentExpressions, dependentExpressions, indNode, metadata, dca, bound, makeDep);
    sourceNode.addAsParent(crit);
    if (isLeft) {
        JoinUtil.swapJoinChildren(joinNode);
    }
    return true;
}
Also used : PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) MakeDep(org.teiid.query.sql.lang.Option.MakeDep) JoinType(org.teiid.query.sql.lang.JoinType) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

MakeDep (org.teiid.query.sql.lang.Option.MakeDep)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)1 JoinType (org.teiid.query.sql.lang.JoinType)1 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)1