MCPcopy Create free account
hub / github.com/BlazingDB/blazingsql / is_avg_window_function

Function is_avg_window_function

engine/src/parser/expression_utils.cpp:694–699  ·  view source on GitHub ↗

Due to `avg` window aggregation the OVER clause is repeated three times from Calcite something like: CAST(/(CASE(>(COUNT($0) OVER (PARTITION BY $1), 0), $SUM0($0) OVER (PARTITION BY $1), null:INTEGER), COUNT($0) OVER (PARTITION BY $1))):INTEGER

Source from the content-addressed store, hash-verified

692// something like:
693// CAST(/(CASE(>(COUNT($0) OVER (PARTITION BY $1), 0), $SUM0($0) OVER (PARTITION BY $1), null:INTEGER), COUNT($0) OVER (PARTITION BY $1))):INTEGER
694bool is_avg_window_function(std::string expression) {
695 size_t num_over_clauses = StringUtil::findAndCountAllMatches(expression, "OVER");
696 if (num_over_clauses == 3) return true;
697
698 return false;
699}
700
701// input: max_prices=[MAX($0) OVER (PARTITION BY $2 ORDER BY $0, $1)]
702// output: max_prices=[MAX($0)]

Calls

no outgoing calls

Tested by

no test coverage detected