You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2017/11/22 17:26:21 UTC

[1/4] incubator-trafodion git commit: [TRAFODION-2813] Ignore leading salt columns when checking index compatibility

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 156829272 -> bf6ed1b94


[TRAFODION-2813] Ignore leading salt columns when checking index compatibility


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/25e64a8f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/25e64a8f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/25e64a8f

Branch: refs/heads/master
Commit: 25e64a8fa6a0c91f9451f7b6fa10e52ac03d58c3
Parents: 19c7544
Author: Dave Birdsall <db...@apache.org>
Authored: Mon Nov 20 23:14:29 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Mon Nov 20 23:14:29 2017 +0000

----------------------------------------------------------------------
 core/sql/optimizer/IndexDesc.cpp | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/25e64a8f/core/sql/optimizer/IndexDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/IndexDesc.cpp b/core/sql/optimizer/IndexDesc.cpp
index dfb9593..949308c 100644
--- a/core/sql/optimizer/IndexDesc.cpp
+++ b/core/sql/optimizer/IndexDesc.cpp
@@ -802,10 +802,30 @@ IndexProperty::compareIndexPromise(const IndexProperty *ixProp) const
 
     const IndexDesc * index = getIndexDesc();
     const IndexDesc * otherIndex = ixProp->getIndexDesc();
-    if ( ((IndexColumn *)(index->getIndexKey()[0]).getItemExpr())->getDefinition() != 
-         ((IndexColumn *)(otherIndex->getIndexKey()[0]).getItemExpr())->getDefinition() )
-
-      return INCOMPATIBLE;
+    
+    // If the two indexes have differing leading columns, consider them incompatible.
+    // For this check, we ignore the "_SALT_" column if both are salted.
+    CollIndex columnToCheck = 0;
+    NABoolean done = FALSE;
+    while (!done)
+      {
+        if (columnToCheck >= index->getIndexKey().entries())
+          return INCOMPATIBLE;  // must be one of the indexes is just "_SALT_" (seems unlikely actually)
+        else if (columnToCheck >= otherIndex->getIndexKey().entries())
+          return INCOMPATIBLE;  // must be one of the indexes is just "_SALT_" (seems unlikely actually)
+        else
+          {
+            IndexColumn * indexCol = (IndexColumn *)(index->getIndexKey()[columnToCheck]).getItemExpr();
+            IndexColumn * otherIndexCol = (IndexColumn *)(otherIndex->getIndexKey()[columnToCheck]).getItemExpr();
+            if ( indexCol->getNAColumn()->isSaltColumn() &&
+                 otherIndexCol->getNAColumn()->isSaltColumn() )
+              columnToCheck++;
+            else if ( indexCol->getDefinition() != otherIndexCol->getDefinition() )
+              return INCOMPATIBLE;
+            else
+              done = TRUE;  // leading column (ignoring "_SALT_" if both have "_SALT_") is different
+          }
+      }
 
      CostScalar myKbForLPred = index->getKbForLocalPred();
      CostScalar othKbForLPred = otherIndex->getKbForLocalPred();


[4/4] incubator-trafodion git commit: Merge [TRAFODION-2813] PR 1306 Fix index compatibility pruning logic

Posted by db...@apache.org.
Merge [TRAFODION-2813] PR 1306 Fix index compatibility pruning logic


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/bf6ed1b9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/bf6ed1b9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/bf6ed1b9

Branch: refs/heads/master
Commit: bf6ed1b94ac44d9d15e04854ec9fdf1c4e2b10ec
Parents: 1568292 5631883
Author: Dave Birdsall <db...@apache.org>
Authored: Wed Nov 22 17:24:56 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Wed Nov 22 17:24:56 2017 +0000

----------------------------------------------------------------------
 core/sql/optimizer/IndexDesc.cpp         | 31 +++++++++++++++++++++++----
 core/sql/optimizer/ItemExpr.cpp          | 16 +++++++-------
 core/sql/regress/compGeneral/EXPECTED071 | 26 ++++++++++++++++++++++
 core/sql/regress/compGeneral/TEST071     | 10 +++++++++
 4 files changed, 71 insertions(+), 12 deletions(-)
----------------------------------------------------------------------



[3/4] incubator-trafodion git commit: Second rework: Check divisioning columns, also generator core fix

Posted by db...@apache.org.
Second rework: Check divisioning columns, also generator core fix


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/5631883d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/5631883d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/5631883d

Branch: refs/heads/master
Commit: 5631883d6b2d81c6d34081288889b791cfbbe527
Parents: 20953fe
Author: Dave Birdsall <db...@apache.org>
Authored: Wed Nov 22 01:48:35 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Wed Nov 22 01:48:35 2017 +0000

----------------------------------------------------------------------
 core/sql/optimizer/IndexDesc.cpp         |  9 ++++++---
 core/sql/optimizer/ItemExpr.cpp          | 16 ++++++++--------
 core/sql/regress/compGeneral/EXPECTED071 | 26 ++++++++++++++++++++++++++
 core/sql/regress/compGeneral/TEST071     | 10 ++++++++++
 4 files changed, 50 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5631883d/core/sql/optimizer/IndexDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/IndexDesc.cpp b/core/sql/optimizer/IndexDesc.cpp
index df22a49..742ff96 100644
--- a/core/sql/optimizer/IndexDesc.cpp
+++ b/core/sql/optimizer/IndexDesc.cpp
@@ -810,9 +810,9 @@ IndexProperty::compareIndexPromise(const IndexProperty *ixProp) const
     while (!done)
       {
         if (columnToCheck >= index->getIndexKey().entries())
-          return INCOMPATIBLE;  // must be one of the indexes is just "_SALT_" (seems unlikely actually)
+          return INCOMPATIBLE;  // must be one of the indexes is just "_SALT_" or "_DIVISION_1_" (seems unlikely actually)
         else if (columnToCheck >= otherIndex->getIndexKey().entries())
-          return INCOMPATIBLE;  // must be one of the indexes is just "_SALT_" (seems unlikely actually)
+          return INCOMPATIBLE;  // must be one of the indexes is just "_SALT_" or "_DIVISION_1_" (seems unlikely actually)
         else
           {
             IndexColumn * indexCol = (IndexColumn *)(index->getIndexKey()[columnToCheck]).getItemExpr();
@@ -820,10 +820,13 @@ IndexProperty::compareIndexPromise(const IndexProperty *ixProp) const
             if ( indexCol->getNAColumn()->isSaltColumn() &&
                  otherIndexCol->getNAColumn()->isSaltColumn() )
               columnToCheck++;
+            else if ( indexCol->getNAColumn()->isDivisioningColumn() &&
+                      otherIndexCol->getNAColumn()->isDivisioningColumn() )
+              columnToCheck++;
             else if ( indexCol->getDefinition() != otherIndexCol->getDefinition() )
               return INCOMPATIBLE;
             else
-              done = TRUE;  // leading column (ignoring "_SALT_" if both have "_SALT_") is the same; do Kb checks
+              done = TRUE;  // leading column (ignoring salt, divisioning if both have it) is the same; do Kb checks
           }
       }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5631883d/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index 09cc906..732dfde 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -709,11 +709,11 @@ ItemExpr * ItemExpr::createMirrorPred(ItemExpr *compColPtr,
                                       const ValueIdSet &underlyingCols)
 {
    CMPASSERT(compColPtr->getOperatorType() == ITM_BASECOLUMN);
-   ValueIdSet eics = ((BaseColumn *)compColPtr)->getEIC();
-   ValueId iCol;
-   ItemExpr *compColIndxPtr;
-   eics.getFirst(iCol);
-   compColIndxPtr = iCol.getItemExpr();
+   BaseColumn *bcol = static_cast<BaseColumn *>(compColPtr);
+   // use the basecolumn Veg, using the basecolumn by itself can cause issues
+   // during codegen downstream
+   ValueId egVid = bcol->getTableDesc()->getColumnVEGList()[bcol->getColNumber()];
+   ItemExpr *compColVEGRefPtr = egVid.getItemExpr();
 
    switch (getOperatorType())
      {
@@ -750,7 +750,7 @@ ItemExpr * ItemExpr::createMirrorPred(ItemExpr *compColPtr,
 
               ItemExpr * compPred = new(CmpCommon::statementHeap())
                                       BiRelat(ITM_EQUAL,
-                                              compColIndxPtr,
+                                              compColVEGRefPtr,
                                               (foldedExpr==NULL) ? newCompExpr.getItemExpr() : foldedExpr);
               compPred->synthTypeAndValueId(TRUE);
 
@@ -821,14 +821,14 @@ ItemExpr * ItemExpr::createMirrorPred(ItemExpr *compColPtr,
           if (keyColOnLeft == TRUE)
               compPred = new(CmpCommon::statementHeap())
                 BiRelat(((BiRelat *) this)->getRelaxedComparisonOpType(),
-                                   compColIndxPtr,
+                                   compColVEGRefPtr,
                                    mirroredExpr //newCompExpr.getItemExpr()
                         );
           else
               compPred = new(CmpCommon::statementHeap())
                            BiRelat(((BiRelat *) this)->getRelaxedComparisonOpType(),
                                    mirroredExpr, //newCompExpr.getItemExpr(),
-                                   compColIndxPtr);
+                                   compColVEGRefPtr);
           compPred->synthTypeAndValueId(TRUE);
           return compPred;
           break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5631883d/core/sql/regress/compGeneral/EXPECTED071
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED071 b/core/sql/regress/compGeneral/EXPECTED071
index e07238f..9fa3ec3 100644
--- a/core/sql/regress/compGeneral/EXPECTED071
+++ b/core/sql/regress/compGeneral/EXPECTED071
@@ -1512,6 +1512,32 @@ MTD2        MTD2X2                6       0        0  S       SYSKEY
 
 --- 30 row(s) selected.
 >>
+>>update statistics for table mtd1 on every column;
+
+--- SQL operation complete.
+>>
+>>select store_id, item_id, sale_date, sale_amt
++>from mtd1
++>where item_id = 101 and sale_amt = 100.0 and sale_date between date '2011-06-01' and date '2011-06-30';
+
+STORE_ID     ITEM_ID      SALE_DATE   SALE_AMT             
+-----------  -----------  ----------  ---------------------
+
+          1          101  2011-06-30                 100.00
+
+--- 1 row(s) selected.
+>>
+>>select store_id, item_id, sale_date, sale_amt
++>from mtd1
++>where item_id = 102 and sale_amt = 200.0 and sale_date between date '2011-07-01' and date '2011-08-31';
+
+STORE_ID     ITEM_ID      SALE_DATE   SALE_AMT             
+-----------  -----------  ----------  ---------------------
+
+          2          102  2011-08-02                 200.00
+
+--- 1 row(s) selected.
+>>
 >>set parserflags 1;
 
 --- SQL operation complete.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5631883d/core/sql/regress/compGeneral/TEST071
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/TEST071 b/core/sql/regress/compGeneral/TEST071
index 09ef16a..d002f59 100644
--- a/core/sql/regress/compGeneral/TEST071
+++ b/core/sql/regress/compGeneral/TEST071
@@ -753,6 +753,16 @@ order by 1, 2, 3
 
 execute smdixquery;
 
+update statistics for table mtd1 on every column;
+
+select store_id, item_id, sale_date, sale_amt
+from mtd1
+where item_id = 101 and sale_amt = 100.0 and sale_date between date '2011-06-01' and date '2011-06-30';
+
+select store_id, item_id, sale_date, sale_amt
+from mtd1
+where item_id = 102 and sale_amt = 200.0 and sale_date between date '2011-07-01' and date '2011-08-31';
+
 set parserflags 1;
 -- validate contents of index against base table after create index
 select count(*) from mtd1;


[2/4] incubator-trafodion git commit: Rework; fix comment

Posted by db...@apache.org.
Rework; fix comment


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/20953fe7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/20953fe7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/20953fe7

Branch: refs/heads/master
Commit: 20953fe74d70349bc1a7600bbcf6565d94defe25
Parents: 25e64a8
Author: Dave Birdsall <db...@apache.org>
Authored: Tue Nov 21 17:19:16 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Tue Nov 21 17:19:16 2017 +0000

----------------------------------------------------------------------
 core/sql/optimizer/IndexDesc.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/20953fe7/core/sql/optimizer/IndexDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/IndexDesc.cpp b/core/sql/optimizer/IndexDesc.cpp
index 949308c..df22a49 100644
--- a/core/sql/optimizer/IndexDesc.cpp
+++ b/core/sql/optimizer/IndexDesc.cpp
@@ -823,7 +823,7 @@ IndexProperty::compareIndexPromise(const IndexProperty *ixProp) const
             else if ( indexCol->getDefinition() != otherIndexCol->getDefinition() )
               return INCOMPATIBLE;
             else
-              done = TRUE;  // leading column (ignoring "_SALT_" if both have "_SALT_") is different
+              done = TRUE;  // leading column (ignoring "_SALT_" if both have "_SALT_") is the same; do Kb checks
           }
       }