Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

[TRAFODION-2246] group by rollup feature #733

Merged
merged 4 commits into from Sep 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions core/sql/bin/SqlciErrors.txt
Expand Up @@ -1372,6 +1372,7 @@ $1~String1 --------------------------------
4381 42000 99999 BEGINNER MINOR LOGONLY Holdable cursor attribute is incompatible for the isolation level.
4382 42000 99999 BEGINNER MINOR LOGONLY Holdable cursor attribute cannot be set for a CALL statement.
4383 ZZZZZ 99999 BEGINNER MINOR DBADMIN A float value cannot be inserted into a numeric data type column $0~ColumnName, if the column is part of the partitioning key.
4384 ZZZZZ 99999 BEGINNER MINOR DBADMIN GROUP BY ROLLUP clause not allowed for this statement. Reason: $0~String0
4390 ZZZZZ 99999 BEGINNER MAJOR DBADMIN The OLAP History row size exceeds the limit of $0~Int0 bytes
4391 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Paramaters and outer references in the PARTITION BY or ORDER BY clause of a window function are not supported.
4400 ZZZZZ 99999 BEGINNER MAJOR LOGONLY Internal error
Expand Down
3 changes: 2 additions & 1 deletion core/sql/comexe/ComTdbSortGrby.cpp
Expand Up @@ -83,7 +83,8 @@ ComTdbSortGrby::ComTdbSortGrby(ex_expr * aggr_expr,
moveExpr_(move_expr),
havingExpr_(having_expr),
flags_(0),
tdbChild_(child_tdb)
tdbChild_(child_tdb),
numRollupGroups_(-1)
{
if (tolerateNonFatalError)
setTolerateNonFatalError(TRUE);
Expand Down
23 changes: 18 additions & 5 deletions core/sql/comexe/ComTdbSortGrby.h
Expand Up @@ -46,8 +46,14 @@
class ComTdbSortGrby : public ComTdb
{
friend class ex_sort_grby_tcb;
friend class ex_sort_grby_rollup_tcb;
friend class ex_sort_grby_private_state;

protected:
enum
{
IS_ROLLUP = 0x0001
};

ComTdbPtr tdbChild_; // 00-07
ExExprPtr aggrExpr_; // 08-15
Expand All @@ -63,7 +69,9 @@ class ComTdbSortGrby : public ComTdb

UInt16 flags_; // 46-47

char fillersComTdbSortGrby_[40]; // 48-87
Int16 numRollupGroups_; // 48-49

char fillersComTdbSortGrby_[38]; // 50-87

public:
// Constructor
Expand All @@ -90,6 +98,9 @@ NA_EIDPROC
NA_EIDPROC
~ComTdbSortGrby();

void setNumRollupGroups(Int16 v) { numRollupGroups_ = v; }
Int16 numRollupGroups() { return numRollupGroups_; }

// ---------------------------------------------------------------------
// Redefine virtual functions required for Versioning.
//----------------------------------------------------------------------
Expand All @@ -106,8 +117,6 @@ NA_EIDPROC
ComTdb::populateImageVersionIDArray();
}



NA_EIDPROC
virtual short getClassSize() { return (short)sizeof(ComTdbSortGrby); }
Long pack(void *);
Expand Down Expand Up @@ -163,7 +172,11 @@ NA_EIDPROC
else
return NULL;
}


NABoolean isRollup() {return ((flags_ & IS_ROLLUP) != 0);};
void setIsRollup(NABoolean v)
{(v ? flags_ |= IS_ROLLUP : flags_ &= ~IS_ROLLUP);}

};

NA_EIDPROC
Expand All @@ -175,7 +188,7 @@ inline ComTdb * ComTdbSortGrby::getChildTdb(){
Description : Return ComTdb* depending on the position argument.
Position 0 means the left most child.
Comments :
History : Yeogirl Yun 8/22/95
History :
Initial Revision.
*****************************************************************************/
inline const ComTdb* ComTdbSortGrby::getChild(Int32 pos) const
Expand Down
14 changes: 14 additions & 0 deletions core/sql/executor/ex_globals.h
Expand Up @@ -198,6 +198,9 @@ NA_EIDPROC

Int64 &rowNum() { return rowNum_; }

void setRollupColumnNum(Int16 v) { rollupColumnNum_ = v; }
Int16 getRollupColumnNum() { return rollupColumnNum_; }

private:
enum FlagsTypeEnum
{
Expand Down Expand Up @@ -277,6 +280,17 @@ NA_EIDPROC
// Executor code does not access the contents.
// void * lobGlob_;

// This value is set when grouping expression to compute rollup is
// evaluated. Caller (sort_grby_rollup_tcb) need to know the number
// of the grouping column that caused a comparison to fail.
// This value is set during comp clause eval. Caller resets it before and
// after call to expression evaluator.
// It is only a short duration global setting used to pass info from/to
// executor to expressions.
// also see class ex_comp_clause in exp/exp_clause_derived.h and ex_sort_grby_rollup_tcb
// on its usage.
Int16 rollupColumnNum_;

};

#endif
Expand Down