MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / tryGetModuloSumPredicateInputs

Function tryGetModuloSumPredicateInputs

src/processor/map/map_aggregate.cpp:143–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143static std::optional<std::pair<std::shared_ptr<Expression>, std::shared_ptr<Expression>>>
144tryGetModuloSumPredicateInputs(const std::shared_ptr<Expression>& predicate) {
145 if (!isScalarFunction(predicate, function::EqualsFunction::name) ||
146 predicate->getNumChildren() != 2) {
147 return std::nullopt;
148 }
149 auto modulo = predicate->getChild(0);
150 auto zero = predicate->getChild(1);
151 if (isInt64Literal(modulo, 0)) {
152 std::swap(modulo, zero);
153 }
154 if (!isInt64Literal(zero, 0) || !isScalarFunction(modulo, function::ModuloFunction::name) ||
155 modulo->getNumChildren() != 2 || !isInt64Literal(modulo->getChild(1), 10)) {
156 return std::nullopt;
157 }
158 auto add = modulo->getChild(0);
159 if (!isScalarFunction(add, function::AddFunction::name) || add->getNumChildren() != 2) {
160 return std::nullopt;
161 }
162 return std::make_pair(add->getChild(0), add->getChild(1));
163}
164
165static std::unique_ptr<PhysicalOperator> tryMapPackedFilteredCount(PlanMapper& mapper,
166 main::ClientContext* clientContext, const LogicalAggregate& agg) {

Callers 1

Calls 4

isScalarFunctionFunction · 0.85
isInt64LiteralFunction · 0.85
getNumChildrenMethod · 0.80
getChildMethod · 0.45

Tested by

no test coverage detected