Matthew Jacobs has posted comments on this change. Change subject: IMPALA-4738: STDDEV_SAMP should return NULL for single record input ......................................................................
Patch Set 1: (1 comment) I think you need a new finalize function to separate stddev and stddev_samp http://gerrit.cloudera.org:8080/#/c/5800/1/be/src/exprs/aggregate-functions-ir.cc File be/src/exprs/aggregate-functions-ir.cc: PS1, Line 1348: DoubleVal AggregateFunctions::KnuthStddevFinalize(FunctionContext* ctx, : const StringVal& state_sv) { : DCHECK(!state_sv.is_null); : DCHECK_EQ(state_sv.len, sizeof(KnuthVarianceState)); : KnuthVarianceState* state = reinterpret_cast<KnuthVarianceState*>(state_sv.ptr); : if (state->count == 0 || state->count == 1) return DoubleVal::null(); : re this gets used by both stddev and stddev_samp, but it looks like Oracle (not sure about other DBs) do not return null for stddev when there is 1 row: https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions159.htm ... It differs from STDDEV_SAMP in that STDDEV returns zero when it has only 1 row of input data, whereas STDDEV_SAMP returns null. ... -- To view, visit http://gerrit.cloudera.org:8080/5800 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ide8af752cd8a2e554a2cd5a1ec948967a80de1fe Gerrit-PatchSet: 1 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: anujphadke <[email protected]> Gerrit-Reviewer: Matthew Jacobs <[email protected]> Gerrit-HasComments: Yes
