Github user zellerh commented on a diff in the pull request:

    
https://github.com/apache/incubator-trafodion/pull/1306#discussion_r152346606
  
    --- Diff: 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() )
    --- End diff --
    
    Just wanted to bring this up, I can also live with both solutions. The 
computation of predicates for salt and division columns is similar, both are 
computed from user columns. The main difference is that the expressions of 
divisioning columns are monotonically increasing. I would have thought that the 
following indexes should be treated as incompatible:
    
    create index ix1 on t(a) division like table;
    create index ix2 on t(b) division like table;


---

Reply via email to