// requires: caseForOuterJoins corresponds the slot "slotNum" // effects: Adds a WhenThen corresponding to child to caseForOuterJoins. private void AddCaseForOuterJoins(CaseStatement caseForOuterJoins, CqlBlock child, int slotNum, CqlIdentifiers identifiers) { // Determine the cells that the slot comes from // and make an OR expression, e.g., WHEN _from0 or _from2 or ... THEN child[slotNum] var childSlot = child.SlotValue(slotNum); var constantSlot = childSlot as ConstantProjectedSlot; if (constantSlot != null && constantSlot.CellConstant.IsNull()) { // NULL being generated by a child - don't need to project return; } var originBool = BoolExpression.False; for (var i = 0; i < NumBoolSlots; i++) { var boolSlotNum = BoolIndexToSlot(i); if (child.IsProjected(boolSlotNum)) { // OR it to the expression var boolExpr = new QualifiedCellIdBoolean(child, identifiers, i); originBool = BoolExpression.CreateOr(originBool, BoolExpression.CreateLiteral(boolExpr, RightDomainMap)); } } // Qualify the slotNum with the child.CqlAlias for the THEN var slot = child.QualifySlotWithBlockAlias(slotNum); caseForOuterJoins.AddWhenThen(originBool, slot); }
private void AddCaseForOuterJoins( CaseStatement caseForOuterJoins, CqlBlock child, int slotNum, CqlIdentifiers identifiers) { ConstantProjectedSlot constantProjectedSlot = child.SlotValue(slotNum) as ConstantProjectedSlot; if (constantProjectedSlot != null && constantProjectedSlot.CellConstant.IsNull()) { return; } BoolExpression or = BoolExpression.False; for (int index = 0; index < this.NumBoolSlots; ++index) { int slot = this.BoolIndexToSlot(index); if (child.IsProjected(slot)) { QualifiedCellIdBoolean qualifiedCellIdBoolean = new QualifiedCellIdBoolean(child, identifiers, index); or = BoolExpression.CreateOr(or, BoolExpression.CreateLiteral((BoolLiteral)qualifiedCellIdBoolean, this.RightDomainMap)); } } QualifiedSlot qualifiedSlot = child.QualifySlotWithBlockAlias(slotNum); caseForOuterJoins.AddWhenThen(or, (ProjectedSlot)qualifiedSlot); }