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

Method createWindowFrame

bolt/exec/Window.cpp:291–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}; // namespace
290
291Window::WindowFrame Window::createWindowFrame(
292 const std::shared_ptr<const core::WindowNode>& windowNode,
293 const core::WindowNode::Frame& frame,
294 const RowTypePtr& inputType) {
295 if (frame.type == core::WindowNode::WindowType::kRows) {
296 checkRowFrameBounds(frame);
297 }
298
299 if (frame.type == core::WindowNode::WindowType::kRange &&
300 (frame.startValue || frame.endValue)) {
301 checkKRangeFrameBounds(windowNode, frame, inputType);
302 }
303
304 auto createFrameChannelArg =
305 [&](const core::TypedExprPtr& frame) -> std::optional<FrameChannelArg> {
306 // frame is nullptr for non (kPreceding or kFollowing) frames.
307 if (frame == nullptr) {
308 return std::nullopt;
309 }
310 auto frameChannel = exprToChannel(frame.get(), inputType);
311 if (frameChannel == kConstantChannel) {
312 auto constant = core::TypedExprs::asConstant(frame)->value();
313 BOLT_CHECK(!constant.isNull(), "Window frame offset must not be null");
314 auto value = VariantConverter::convert(constant, TypeKind::BIGINT)
315 .value<int64_t>();
316 BOLT_USER_CHECK_GE(
317 value, 0, "Window frame {} offset must not be negative", value);
318 return std::make_optional(
319 FrameChannelArg{kConstantChannel, nullptr, value});
320 } else {
321 return std::make_optional(FrameChannelArg{
322 frameChannel,
323 BaseVector::create(frame->type(), 0, pool()),
324 std::nullopt});
325 }
326 };
327
328 auto startFrameArg = createFrameChannelArg(frame.startValue);
329 auto endFrameArg = createFrameChannelArg(frame.endValue);
330 return WindowFrame(
331 {frame.type,
332 frame.startType,
333 frame.endType,
334 std::move(startFrameArg),
335 std::move(endFrameArg)});
336}
337
338void Window::createWindowFunctions() {
339 BOLT_CHECK_NOT_NULL(windowNode_);

Callers

nothing calls this directly

Calls 11

checkRowFrameBoundsFunction · 0.85
checkKRangeFrameBoundsFunction · 0.85
exprToChannelFunction · 0.85
convertFunction · 0.85
WindowFrameClass · 0.85
createFunction · 0.50
poolFunction · 0.50
getMethod · 0.45
valueMethod · 0.45
isNullMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected