//---------------------------------------------------------------------------- // Prepare for creating the SYS_CALC columns, by divide the list of MAV // columns to 4 groups: // 1. GroupBy columns - inserted directly into the RETDesc without change. // 2. COUNT columns - collected in countCols_, done in phase1. // 3. SUM, MIN and MAX columns - collected in sumCols_, done in phase2. // 4. AVG, STDDEV, VARIANCE cols - collected in otherCols_, done in phase3. void MavRelRootBuilder::init() { // Divide the MAV columns to groups: for (CollIndex i=0; i<mavCols_.entries(); i++) { #pragma nowarn(1506) // warning elimination MVColumnInfo *currentCol = mavCols_[i]; #pragma warn(1506) // warning elimination if (currentCol->getColType() != COM_MVCOL_AGGREGATE) { // This is a group-by column, or a constant that does not change. groupByCols_.insert(currentCol); } else { // This is an aggregate column. insert into the correct list. switch (currentCol->getOperatorType()) { case ITM_COUNT: case ITM_COUNT_NONULL: // No dependent columns, done in phase1. countCols_.insert(currentCol); break; case ITM_SUM: case ITM_MIN: case ITM_MAX: // Use the SYS_CALC COUNT columns, done in phase2. sumCols_.insert(currentCol); break; case ITM_AVG: case ITM_STDDEV: case ITM_VARIANCE: // Use the SYS_CALC COUNT and SUM columns, done in phase3. otherCols_.insert(currentCol); break; default: CMPASSERT(FALSE); } } } } // MavRelRootBuilder::init()
////////////////////////////////////////////////////////////////////////////// // Does this base table have a supporting index on the MAV GroupBy columns? // (Supporting index means that the MAV GroupBy columns must be a prefix // of the index columns). ////////////////////////////////////////////////////////////////////////////// NABoolean Refresh::doesBaseTableHaveSupportingIndex(BindWA *bindWA, MVInfoForDML *mvInfo) const { CollIndex i; LIST (MVUsedObjectInfo*)& UsedObjList = mvInfo->getUsedObjectsList(); MVUsedObjectInfo* pUsedTable = UsedObjList[0]; // Extract GroupBy columns const MVColumns& pMvInfoColumnList = mvInfo->getMVColumns(); LIST (MVColumnInfo *) mvGroupByColumns(bindWA->wHeap()); for ( i = 0 ; i < pMvInfoColumnList.entries() ; i++) { #pragma nowarn(1506) // warning elimination MVColumnInfo *currentMvColInfo = pMvInfoColumnList[i]; #pragma warn(1506) // warning elimination if (COM_MVCOL_GROUPBY == currentMvColInfo->getColType()) { mvGroupByColumns.insert(currentMvColInfo); } } // If the MAV does not have any group by columns - than there is // no supporting index. if (mvGroupByColumns.entries() == 0) return FALSE; // Get the NATable QualifiedName underlyingTableName = pUsedTable->getObjectName(); CorrName corrTableName(underlyingTableName); NATable * pNaTable = bindWA->getNATable(corrTableName, FALSE); // Construct table GroupBy NAColumnArray tableGroupByArray; const NAColumnArray & columnArray = pNaTable->getNAColumnArray(); for ( i = 0 ; i < mvGroupByColumns.entries() ; i++) { Int32 tableColNum = (mvGroupByColumns)[i]->getOrigColNumber(); NAColumn * pColumn = columnArray.getColumn(tableColNum); tableGroupByArray.insert(pColumn); } // Check the clustering Index. const NAFileSet *pClusteringIndexFileSet = pNaTable->getClusteringIndex(); const NAColumnArray& ciColumns = pClusteringIndexFileSet->getIndexKeyColumns(); if (TRUE == areGroupByColsAnIndexPrefix(tableGroupByArray, ciColumns)) { return TRUE; } // Check any secondary indices. const NAFileSetList & indexFileSetList = pNaTable->getIndexList(); for ( i = 0 ; i < indexFileSetList.entries() ; i++) { const NAFileSet *pSecondaryIndexFileSet = indexFileSetList[i]; const NAColumnArray& siColumns = pSecondaryIndexFileSet->getIndexKeyColumns(); if (TRUE == areGroupByColsAnIndexPrefix(tableGroupByArray, siColumns)) { return TRUE; } } return FALSE; }