Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/218#discussion_r47155717
--- Diff: core/sql/optimizer/GroupAttr.cpp ---
@@ -327,6 +327,38 @@ void GroupAttributes::addConstraint(ItemExpr *c)
}
break;
+ case ITM_CHECK_OPT_CONSTRAINT:
+ {
+ CheckOptConstraint *cc = (CheckOptConstraint *) c;
+
+ // check existing uniqueness constraints whether they are similar
+ // and combine uniqueness constraints if possible
+ for (ValueId occ = constraints_.init();
+ constraints_.next(occ);
+ constraints_.advance(occ))
+ {
+ if (occ.getItemExpr()->getOperatorType() ==
+ ITM_CHECK_OPT_CONSTRAINT)
+ {
+ const ValueIdSet &occPreds =
+ ((CheckOptConstraint *)
occ.getItemExpr())->getCheckPreds();
+
+ if (occPreds.contains(cc->getCheckPreds()))
--- End diff --
A question about how this works (more from my own ignorance): Does
"contains" do a semantic comparison? Or just a ValueId comparison? For example,
if I code two CHECK CONSTRAINTS with predicates A < B and A < B, is the ValueId
of the '<' the same for both? And how is that accomplished? Similarly, if I
have two CHECK CONSTRAINTS with predicates A < B and B > A, will the second be
normalized back to A < B and get the same ValueId?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---