if (StringUtil.startsWithIgnoreCase(hint, "make")) { //$NON-NLS-1$ if (hint.equalsIgnoreCase(Option.MAKENOTDEP)) { fromClause.setMakeNotDep(true); } else if (StringUtil.startsWithIgnoreCase(hint, Option.MAKEDEP)) { Option.MakeDep option = new Option.MakeDep(); fromClause.setMakeDep(option); parseOptions(m, option); } else if (StringUtil.startsWithIgnoreCase(hint, SQLConstants.Reserved.MAKEIND)) { Option.MakeDep option = new Option.MakeDep(); fromClause.setMakeInd(option); parseOptions(m, option); fromClause.setNoUnnest(true); } else if (hint.equalsIgnoreCase(FromClause.PRESERVE)) { fromClause.setPreserve(true); } else if (hint.equalsIgnoreCase(Option.OPTIONAL)) { fromClause.setOptional(true);
/** * Return deep clone for object * @return Deep clone */ protected FromClause cloneDirect() { FromClause copyLeft = null; if(this.leftClause != null) { copyLeft = this.leftClause.clone(); } FromClause copyRight = null; if(this.rightClause != null) { copyRight = this.rightClause.clone(); } List copyCrits = null; if(this.joinCriteria != null) { copyCrits = new ArrayList(joinCriteria.size()); Iterator iter = this.joinCriteria.iterator(); while(iter.hasNext()) { Criteria crit = (Criteria) iter.next(); copyCrits.add(crit.clone()); } } JoinPredicate clonedJoinPredicate = new JoinPredicate(copyLeft, copyRight, this.joinType, copyCrits); return clonedJoinPredicate; }
public FromClause clone() { FromClause clone = cloneDirect(); clone.makeDep = makeDep; clone.makeInd = makeInd; clone.makeNotDep = makeNotDep; clone.optional = optional; clone.noUnnest = noUnnest; clone.preserve = preserve; return clone; }
public boolean equals(Object obj) { if(obj == this) { return true; } if(! (obj instanceof FromClause)) { return false; } FromClause other = (FromClause)obj; return other.isOptional() == this.isOptional() && EquivalenceUtil.areEqual(this.makeDep, other.makeDep) && other.isMakeNotDep() == this.isMakeNotDep() && EquivalenceUtil.areEqual(this.makeInd, other.makeInd) && other.isNoUnnest() == this.isNoUnnest() && other.isNoUnnest() == this.isNoUnnest(); }
private void addHintComment( FromClause obj ) { if (obj.hasHint()) { append(BEGIN_HINT); append(SPACE); if (obj.isOptional()) { append(Option.OPTIONAL); append(SPACE); if (obj.getMakeDep() != null) { append(Option.MAKEDEP); appendMakeDepOptions(obj.getMakeDep()); append(SPACE); if (obj.isMakeNotDep()) { append(Option.MAKENOTDEP); append(SPACE); if (obj.getMakeInd() != null) { append(MAKEIND); appendMakeDepOptions(obj.getMakeInd()); append(SPACE); if (obj.isNoUnnest()) { append(SubqueryHint.NOUNNEST); append(SPACE); if (obj.isPreserve()) { append(FromClause.PRESERVE); append(SPACE);
jj_consume_token(MAKEDEP); makedep = makedepOptions(); clause.setMakeDep(makedep); break; case MAKENOTDEP: jj_consume_token(MAKENOTDEP); clause.setMakeNotDep(true); break; default: jj_consume_token(MAKEIND); makedep = makedepOptions(); clause.setMakeInd(makedep); break; default:
if (clause.isOptional()) { node.setProperty(NodeConstants.Info.IS_OPTIONAL, Boolean.TRUE); if (clause.getMakeDep() != null) { node.setProperty(NodeConstants.Info.MAKE_DEP, clause.getMakeDep()); } else if (clause.isMakeNotDep()) { node.setProperty(NodeConstants.Info.MAKE_NOT_DEP, Boolean.TRUE); if (clause.getMakeInd() != null) { node.setProperty(NodeConstants.Info.MAKE_IND, clause.getMakeInd());
@Test public void testDepOptions2() { GroupSymbol a = new GroupSymbol("a"); //$NON-NLS-1$ GroupSymbol b = new GroupSymbol("b"); //$NON-NLS-1$ ElementSymbol x = new ElementSymbol("a.x", true); //$NON-NLS-1$ ElementSymbol y = new ElementSymbol("b.y", true); //$NON-NLS-1$ Criteria criteria = new CompareCriteria(x, CompareCriteria.EQ, new Function("func", new Expression[] {y})); //$NON-NLS-1$ JoinPredicate predicate = new JoinPredicate(new UnaryFromClause(a), new UnaryFromClause(b), JoinType.JOIN_INNER, Arrays.asList(new Object[] {criteria})); From from = new From(Arrays.asList(predicate)); predicate.getLeftClause().setMakeNotDep(true); predicate.getRightClause().setMakeDep(true); Select select = new Select(Arrays.asList(x, y)); Query query = new Query(select, from, null, null, null, null, null); TestParser.helpTest("Select a.x, b.y From a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = func(b.y)", //$NON-NLS-1$ "SELECT a.x, b.y FROM /*+ MAKENOTDEP */ a INNER JOIN /*+ MAKEDEP */ b ON a.x = func(b.y)", //$NON-NLS-1$ query); }
/** * Collect all GroupSymbols for this from clause. * @param groups Groups to add to */ public void collectGroups(Collection<GroupSymbol> groups) { if(this.leftClause != null) { this.leftClause.collectGroups(groups); } if(this.rightClause != null) { this.rightClause.collectGroups(groups); } }
/** * Check whether objects are equal * @param obj Other object * @return True if equal */ public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } if(! (obj instanceof SubqueryFromClause)) { return false; } SubqueryFromClause sfc = (SubqueryFromClause) obj; return this.getName().equalsIgnoreCase(sfc.getName()) && sfc.isOptional() == this.isOptional() && this.command.equals(sfc.command) && this.lateral == sfc.lateral; }
@Test public void testOptionMakeNotDepInline3(){ GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$ GroupSymbol g2 = new GroupSymbol("db.g2"); //$NON-NLS-1$ GroupSymbol g3 = new GroupSymbol("db.g3"); //$NON-NLS-1$ ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$ ElementSymbol b = new ElementSymbol("b"); //$NON-NLS-1$ ElementSymbol c = new ElementSymbol("c"); //$NON-NLS-1$ List<Object> crits = new ArrayList<Object>(); crits.add(new CompareCriteria(a, CompareCriteria.EQ, b)); JoinPredicate jp = new JoinPredicate(new UnaryFromClause(g1), new UnaryFromClause(g2), JoinType.JOIN_INNER, crits); jp.getLeftClause().setMakeNotDep(true); List<Object> crits2 = new ArrayList<Object>(); crits2.add(new CompareCriteria(a, CompareCriteria.EQ, c)); JoinPredicate jp2 = new JoinPredicate(jp, new UnaryFromClause(g3), JoinType.JOIN_LEFT_OUTER, crits2); jp2.getRightClause().setMakeNotDep(true); From from = new From(); from.addClause(jp2); Select select = new Select(); select.addSymbol(a); Query query = new Query(); query.setSelect(select); query.setFrom(from); TestParser.helpTest("Select a From (db.g1 MAKENOTDEP JOIN db.g2 ON a = b) LEFT OUTER JOIN db.g3 MAKENOTDEP ON a = c", //$NON-NLS-1$ "SELECT a FROM (/*+ MAKENOTDEP */ db.g1 INNER JOIN db.g2 ON a = b) LEFT OUTER JOIN /*+ MAKENOTDEP */ db.g3 ON a = c", //$NON-NLS-1$ query); }
@Test public void testOptionMakeDepInline3(){ GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$ GroupSymbol g2 = new GroupSymbol("db.g2"); //$NON-NLS-1$ GroupSymbol g3 = new GroupSymbol("db.g3"); //$NON-NLS-1$ ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$ ElementSymbol b = new ElementSymbol("b"); //$NON-NLS-1$ ElementSymbol c = new ElementSymbol("c"); //$NON-NLS-1$ List<Object> crits = new ArrayList<Object>(); crits.add(new CompareCriteria(a, CompareCriteria.EQ, b)); JoinPredicate jp = new JoinPredicate(new UnaryFromClause(g1), new UnaryFromClause(g2), JoinType.JOIN_INNER, crits); jp.getLeftClause().setMakeDep(true); List<Object> crits2 = new ArrayList<Object>(); crits2.add(new CompareCriteria(a, CompareCriteria.EQ, c)); JoinPredicate jp2 = new JoinPredicate(jp, new UnaryFromClause(g3), JoinType.JOIN_LEFT_OUTER, crits2); jp2.getRightClause().setMakeDep(true); From from = new From(); from.addClause(jp2); Select select = new Select(); select.addSymbol(a); Query query = new Query(); query.setSelect(select); query.setFrom(from); TestParser.helpTest("Select a From (db.g1 MAKEDEP JOIN db.g2 ON a = b) LEFT OUTER JOIN db.g3 MAKEDEP ON a = c", //$NON-NLS-1$ "SELECT a FROM (/*+ MAKEDEP */ db.g1 INNER JOIN db.g2 ON a = b) LEFT OUTER JOIN /*+ MAKEDEP */ db.g3 ON a = c", //$NON-NLS-1$ query); }
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); } }
private void addHintComment( FromClause obj ) { if (obj.hasHint()) { append(BEGIN_HINT); append(SPACE); if (obj.isOptional()) { append(Option.OPTIONAL); append(SPACE); if (obj.getMakeDep() != null) { append(Option.MAKEDEP); appendMakeDepOptions(obj.getMakeDep()); append(SPACE); if (obj.isMakeNotDep()) { append(Option.MAKENOTDEP); append(SPACE); if (obj.getMakeInd() != null) { append(MAKEIND); appendMakeDepOptions(obj.getMakeInd()); append(SPACE); if (obj.isNoUnnest()) { append(SubqueryHint.NOUNNEST); append(SPACE); if (obj.isPreserve()) { append(FromClause.PRESERVE); append(SPACE);
jj_consume_token(MAKEDEP); makedep = makedepOptions(); clause.setMakeDep(makedep); break; case MAKENOTDEP: jj_consume_token(MAKENOTDEP); clause.setMakeNotDep(true); break; default: jj_consume_token(MAKEIND); makedep = makedepOptions(); clause.setMakeInd(makedep); break; default:
if (clause.isOptional()) { node.setProperty(NodeConstants.Info.IS_OPTIONAL, Boolean.TRUE); if (clause.getMakeDep() != null) { node.setProperty(NodeConstants.Info.MAKE_DEP, clause.getMakeDep()); } else if (clause.isMakeNotDep()) { node.setProperty(NodeConstants.Info.MAKE_NOT_DEP, Boolean.TRUE); if (clause.getMakeInd() != null) { node.setProperty(NodeConstants.Info.MAKE_IND, clause.getMakeInd());
public boolean equals(Object obj) { if(obj == this) { return true; } if(! (obj instanceof FromClause)) { return false; } FromClause other = (FromClause)obj; return other.isOptional() == this.isOptional() && EquivalenceUtil.areEqual(this.makeDep, other.makeDep) && other.isMakeNotDep() == this.isMakeNotDep() && EquivalenceUtil.areEqual(this.makeInd, other.makeInd) && other.isNoUnnest() == this.isNoUnnest() && other.isNoUnnest() == this.isNoUnnest(); }
/** * Collect all GroupSymbols for this from clause. * @param groups Groups to add to */ public void collectGroups(Collection<GroupSymbol> groups) { if(this.leftClause != null) { this.leftClause.collectGroups(groups); } if(this.rightClause != null) { this.rightClause.collectGroups(groups); } }
/** * Check whether objects are equal * @param obj Other object * @return True if equal */ public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } if(! (obj instanceof SubqueryFromClause)) { return false; } SubqueryFromClause sfc = (SubqueryFromClause) obj; return this.getName().equalsIgnoreCase(sfc.getName()) && sfc.isOptional() == this.isOptional() && this.command.equals(sfc.command) && this.lateral == sfc.lateral; }
@Test public void testOptionMakeNotDepInline4(){ GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$ GroupSymbol g2 = new GroupSymbol("c", "db.g2"); //$NON-NLS-1$ //$NON-NLS-2$ ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$ ElementSymbol b = new ElementSymbol("b"); //$NON-NLS-1$ CompareCriteria crit = new CompareCriteria(a, CompareCriteria.EQ, b); From from = new From(); FromClause clause = new UnaryFromClause(g1); clause.setMakeNotDep(true); from.addClause(clause); FromClause clause1 = new UnaryFromClause(g2); clause1.setMakeNotDep(true); from.addClause(clause1); Select select = new Select(); select.addSymbol(a); Query query = new Query(); query.setSelect(select); query.setFrom(from); query.setCriteria(crit); TestParser.helpTest("Select a From db.g1 MAKENOTDEP, db.g2 AS c MAKENOTDEP WHERE a = b", //$NON-NLS-1$ "SELECT a FROM /*+ MAKENOTDEP */ db.g1, /*+ MAKENOTDEP */ db.g2 AS c WHERE a = b", //$NON-NLS-1$ query); }