[GitHub] incubator-trafodion pull request #639: [TRAFODION-2117] add SQL support of E...

2016-08-08 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-trafodion/pull/639


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-trafodion pull request #639: [TRAFODION-2117] add SQL support of E...

2016-08-05 Thread traflm
Github user traflm commented on a diff in the pull request:

https://github.com/apache/incubator-trafodion/pull/639#discussion_r73779962
  
--- Diff: core/sql/optimizer/RelExpr.cpp ---
@@ -6630,6 +6630,23 @@ const NAString Intersect::getText() const
 }
 
 // ---
+// // member functions for class Except
+// // 
---
+Except::Except(RelExpr *leftChild,
+ RelExpr *rightChild)
+: RelExpr(REL_EXCEPT, leftChild, rightChild)
+{ setNonCacheable(); }
--- End diff --

I don't know either, but SET operations like UNION is also set as non 
cacheable. So I feel we should keep it now. I will try to study more on this 
later.

showshape works:
>>showshape select eno,ename,dno from t021 except select * from t022;
I
control query shape hybrid_hash_join(scan(path 'TRAFODION.SEABASE.T021',
forward, blocks_per_access 1 , mdam off),
scan(path 'TRAFODION.SEABASE.T022', forward, blocks_per_access 1
, mdam off));

--- SQL operation complete.
>>



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-trafodion pull request #639: [TRAFODION-2117] add SQL support of E...

2016-08-05 Thread traflm
Github user traflm commented on a diff in the pull request:

https://github.com/apache/incubator-trafodion/pull/639#discussion_r73779753
  
--- Diff: core/sql/optimizer/BindRelExpr.cpp ---
@@ -3035,6 +3035,98 @@ RelExpr *Intersect::bindNode(BindWA *bindWA)
 // LCOV_EXCL_STOP
 
 // ---
+// member functions for class Except 
+// ---
+
+// LCOV_EXCL_START - cnu
+RelExpr *Except::bindNode(BindWA *bindWA)
+{
+  if (nodeIsBound())
+  {
+bindWA->getCurrentScope()->setRETDesc(getRETDesc());
+return this;
+  }
+
+  // Bind the child nodes.
+  //
+  bindChildren(bindWA);
+  if (bindWA->errStatus()) return this;
+
+  // Check that there are an equal number of select items on both sides.
+  //
+  const RETDesc &leftTable = *child(0)->getRETDesc();
+  const RETDesc &rightTable = *child(1)->getRETDesc();
+  if (leftTable.getDegree() != rightTable.getDegree()) {
+// 4014 The operands of an intersect must be of equal degree.
+*CmpCommon::diags() << DgSqlCode(-4014);
+bindWA->setErrStatus();
+return this;
+  }
+
+  // Join the columns of both sides. 
+  //
+  if(CmpCommon::getDefault(MODE_SPECIAL_4) != DF_ON)
--- End diff --

this is not required, but new features not well QAed, I think it is easier 
to be adopted if protected by CQD :-)
After QA tested, we can externalize all these new features: INTERSECT and 
EXCEPT


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-trafodion pull request #639: [TRAFODION-2117] add SQL support of E...

2016-08-05 Thread sureshsubbiah
Github user sureshsubbiah commented on a diff in the pull request:

https://github.com/apache/incubator-trafodion/pull/639#discussion_r73768646
  
--- Diff: core/sql/optimizer/BindRelExpr.cpp ---
@@ -3035,6 +3035,98 @@ RelExpr *Intersect::bindNode(BindWA *bindWA)
 // LCOV_EXCL_STOP
 
 // ---
+// member functions for class Except 
+// ---
+
+// LCOV_EXCL_START - cnu
+RelExpr *Except::bindNode(BindWA *bindWA)
+{
+  if (nodeIsBound())
+  {
+bindWA->getCurrentScope()->setRETDesc(getRETDesc());
+return this;
+  }
+
+  // Bind the child nodes.
+  //
+  bindChildren(bindWA);
+  if (bindWA->errStatus()) return this;
+
+  // Check that there are an equal number of select items on both sides.
+  //
+  const RETDesc &leftTable = *child(0)->getRETDesc();
+  const RETDesc &rightTable = *child(1)->getRETDesc();
+  if (leftTable.getDegree() != rightTable.getDegree()) {
+// 4014 The operands of an intersect must be of equal degree.
+*CmpCommon::diags() << DgSqlCode(-4014);
+bindWA->setErrStatus();
+return this;
+  }
+
+  // Join the columns of both sides. 
+  //
+  if(CmpCommon::getDefault(MODE_SPECIAL_4) != DF_ON)
--- End diff --

I forget now, why is this guarded by MODE_SPECIAL_4 ?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-trafodion pull request #639: [TRAFODION-2117] add SQL support of E...

2016-08-05 Thread sureshsubbiah
Github user sureshsubbiah commented on a diff in the pull request:

https://github.com/apache/incubator-trafodion/pull/639#discussion_r73768268
  
--- Diff: core/sql/optimizer/RelExpr.cpp ---
@@ -6630,6 +6630,23 @@ const NAString Intersect::getText() const
 }
 
 // ---
+// // member functions for class Except
+// // 
---
+Except::Except(RelExpr *leftChild,
+ RelExpr *rightChild)
+: RelExpr(REL_EXCEPT, leftChild, rightChild)
+{ setNonCacheable(); }
--- End diff --

Why is this noncacheable?
Also please check if we can do showshape on a statement with EXCEPT


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-trafodion pull request #639: [TRAFODION-2117] add SQL support of E...

2016-08-05 Thread sureshsubbiah
Github user sureshsubbiah commented on a diff in the pull request:

https://github.com/apache/incubator-trafodion/pull/639#discussion_r73767094
  
--- Diff: core/sql/optimizer/BindRelExpr.cpp ---
@@ -3035,6 +3035,98 @@ RelExpr *Intersect::bindNode(BindWA *bindWA)
 // LCOV_EXCL_STOP
 
 // ---
+// member functions for class Except 
+// ---
+
+// LCOV_EXCL_START - cnu
--- End diff --

This coverage line should be removed in a subsequent checkin.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-trafodion pull request #639: [TRAFODION-2117] add SQL support of E...

2016-08-04 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:

https://github.com/apache/incubator-trafodion/pull/639#discussion_r73565055
  
--- Diff: core/sql/optimizer/BindRelExpr.cpp ---
@@ -3035,6 +3035,98 @@ RelExpr *Intersect::bindNode(BindWA *bindWA)
 // LCOV_EXCL_STOP
 
 // ---
+// member functions for class Except 
+// ---
+
+// LCOV_EXCL_START - cnu
+RelExpr *Except::bindNode(BindWA *bindWA)
+{
+  if (nodeIsBound())
+  {
+bindWA->getCurrentScope()->setRETDesc(getRETDesc());
+return this;
+  }
+
+  // Bind the child nodes.
+  //
+  bindChildren(bindWA);
+  if (bindWA->errStatus()) return this;
+
+  // Check that there are an equal number of select items on both sides.
+  //
+  const RETDesc &leftTable = *child(0)->getRETDesc();
+  const RETDesc &rightTable = *child(1)->getRETDesc();
+  if (leftTable.getDegree() != rightTable.getDegree()) {
+// 4014 The operands of an intersect must be of equal degree.
+*CmpCommon::diags() << DgSqlCode(-4014);
+bindWA->setErrStatus();
+return this;
+  }
+
+  // Join the columns of both sides. 
+  //
+  if(CmpCommon::getDefault(MODE_SPECIAL_4) != DF_ON)
+  {
+*CmpCommon::diags() << DgSqlCode(-3022)// ## INTERSECT not yet 
supported
+<< DgString0("EXCEPT"); // ##
+bindWA->setErrStatus();// ##
+if (bindWA->errStatus()) return NULL;  // ##
+  }
+  //
+  ItemExpr *predicate = intersectColumns(leftTable, rightTable, bindWA);
+  RelExpr *join = new (bindWA->wHeap())
+Join(child(0)->castToRelExpr(),
+ child(1)->castToRelExpr(),
+ REL_ANTI_SEMIJOIN,
+ predicate);
+
+  // Bind the join.
+  //
+  join = join->bindNode(bindWA)->castToRelExpr();
+  if (bindWA->errStatus()) return join;
+
+  // Change the output of the join to just the left side.
+  //
+  delete join->getRETDesc();
+  join->setRETDesc(new (bindWA->wHeap()) RETDesc(bindWA, leftTable));
+  bindWA->getCurrentScope()->setRETDesc(join->getRETDesc());
+
+  // QSTUFF
+  NAString fmtdList1(bindWA->wHeap());
+  LIST(TableNameMap*) xtnmList1(bindWA->wHeap());
+  NAString fmtdList2(bindWA->wHeap());
+  LIST(TableNameMap*) xtnmList2(bindWA->wHeap());
+
+  leftTable.getTableList(xtnmList1, &fmtdList1);
+  rightTable.getTableList(xtnmList2, &fmtdList2);
+
+  if (child(0)->getGroupAttr()->isStream() &&
+  child(1)->getGroupAttr()->isStream()){
+*CmpCommon::diags() << DgSqlCode(-4159)
+<< DgString0(fmtdList1) << DgString1(fmtdList2);
+bindWA->setErrStatus();
+return this;
+  }
+
+  // Needs to be removed when supporting get_next for INTERSECT
--- End diff --

Ditto


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-trafodion pull request #639: [TRAFODION-2117] add SQL support of E...

2016-08-04 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:

https://github.com/apache/incubator-trafodion/pull/639#discussion_r73564989
  
--- Diff: core/sql/optimizer/BindRelExpr.cpp ---
@@ -3035,6 +3035,98 @@ RelExpr *Intersect::bindNode(BindWA *bindWA)
 // LCOV_EXCL_STOP
 
 // ---
+// member functions for class Except 
+// ---
+
+// LCOV_EXCL_START - cnu
+RelExpr *Except::bindNode(BindWA *bindWA)
+{
+  if (nodeIsBound())
+  {
+bindWA->getCurrentScope()->setRETDesc(getRETDesc());
+return this;
+  }
+
+  // Bind the child nodes.
+  //
+  bindChildren(bindWA);
+  if (bindWA->errStatus()) return this;
+
+  // Check that there are an equal number of select items on both sides.
+  //
+  const RETDesc &leftTable = *child(0)->getRETDesc();
+  const RETDesc &rightTable = *child(1)->getRETDesc();
+  if (leftTable.getDegree() != rightTable.getDegree()) {
+// 4014 The operands of an intersect must be of equal degree.
+*CmpCommon::diags() << DgSqlCode(-4014);
+bindWA->setErrStatus();
+return this;
+  }
+
+  // Join the columns of both sides. 
+  //
+  if(CmpCommon::getDefault(MODE_SPECIAL_4) != DF_ON)
+  {
+*CmpCommon::diags() << DgSqlCode(-3022)// ## INTERSECT not yet 
supported
--- End diff --

Comment should say EXCEPT (you can fix it on a later check-in)


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-trafodion pull request #639: [TRAFODION-2117] add SQL support of E...

2016-08-04 Thread traflm
GitHub user traflm opened a pull request:

https://github.com/apache/incubator-trafodion/pull/639

[TRAFODION-2117] add SQL support of EXCEPT

initial support of SQL syntax EXCEPT

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/traflm/incubator-trafodion TRAFODION-2117

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-trafodion/pull/639.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #639


commit 690bb9d81b9fcd5c9463b56c544c676bc773dd2a
Author: Liu Ming 
Date:   2016-08-04T08:25:25Z

[TRAFODION-2117] add SQL support of EXCEPT




---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---