Getting error on using Count with grouping sets

Hi

When I use count along with grouping set as shown below,

SELECT SurveyCategoryID,SurveyFormItemID,ResponseMonth AS GroupByField1,ResponseYear AS GroupByField2,SUM(SumFavourable) AS FavRespCount, SUM(SumScaleOptionValueSum) AS ScaleOptionValueSum,SUM(SumTotalRespondentCount) AS TotalRespCount, COUNT(DISTINCT SurveyParticipantID) AS TotalDistinctRespCount FROM PulseResponse WHERE ClientID = 94 AND SurveyFormID = 21 AND ParticipantStatus = 1 AND SurveyStatusFlag = 3 AND IsRatingScale = 1 GROUP BY GROUPING SETS ((SurveyCategoryID,ResponseMonth,ResponseYear), (SurveyCategoryID), (SurveyFormItemID,SurveyCategoryID,ResponseMonth,ResponseYear), (SurveyFormItemID,SurveyCategoryID))

It’s throwing the below error.

The exception contained withinMappableContainerException couldnot be mapped to a response, re-throwing to the HTTP containerjava.lang.AssertionError: Typemismatch: rowtype of new rel:RecordType(BIGINT NOT NULLResponseQuarter, BIGINT NOT NULLResponseYear, BIGINT NOT NULLSurveyCategoryID, BIGINT NOT NULLSurveyFormItemID, BIGINT NOTNULL FavRespCount, BIGINT NOTNULL ScaleOptionValueSum, BIGINTNOT NULL TotalRespCount, BIGINTNOT NULL TotalDistinctRespCount)NOT NULL rowtype of set:RecordType(BIGINTResponseQuarter, BIGINTResponseYear, BIGINT NOT NULLSurveyCategoryID, BIGINTSurveyFormItemID, BIGINT NOTNULL FavRespCount, BIGINT NOTNULL ScaleOptionValueSum, BIGINTNOT NULL TotalRespCount, BIGINTNOT NULL TotalDistinctRespCount)NOT NULL

But when I use theta sketch it shows result without errors

Oh wow Google User Groups did not like to show me your SQL in a nice clean way!!

After some time in Atom (!!) I wonder: can you reproduce the error with just one of the GROUPing sets? Can you isolate it in some way?

And when you say “use theta sketch”, do you mean using the APPROX_COUNT_DISTINCT_DS_THETA function instead of COUNT?