MCPcopy Create free account
hub / github.com/bytedance/bolt / checkKRangeFrameBounds

Function checkKRangeFrameBounds

bolt/exec/Window.cpp:255–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255void checkKRangeFrameBounds(
256 const std::shared_ptr<const core::WindowNode>& windowNode,
257 const core::WindowNode::Frame& frame,
258 const RowTypePtr& inputType) {
259 // For k Range frame bound:
260 // i) The order by needs to be a single column for bound comparisons
261 // (Checked in WindowNode constructor).
262 // ii) The bounds values are pre-computed in the start(end)Value bound
263 // fields. So, start(end)Value bounds cannot be constants.
264 // iii) The frame bound column and the ORDER BY column must have
265 // the same type for correct comparisons.
266 auto orderByType = windowNode->sortingKeys()[0]->type();
267 auto frameBoundCheck = [&](const core::TypedExprPtr& frameValue) -> void {
268 if (frameValue == nullptr) {
269 return;
270 }
271
272 auto frameChannel = exprToChannel(frameValue.get(), inputType);
273 BOLT_USER_CHECK_NE(
274 frameChannel,
275 kConstantChannel,
276 "Window frame of type RANGE does not support constant arguments");
277
278 auto frameType = inputType->childAt(frameChannel);
279 BOLT_USER_CHECK(
280 *frameType == *orderByType,
281 "Window frame of type RANGE does not match types of the ORDER BY"
282 " and frame column");
283 };
284
285 frameBoundCheck(frame.startValue);
286 frameBoundCheck(frame.endValue);
287}
288
289}; // namespace
290

Callers 1

createWindowFrameMethod · 0.85

Calls 4

exprToChannelFunction · 0.85
childAtMethod · 0.80
typeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected