@@ -996,6 +996,7 @@ base::Status ConvertExprNodeList(const absl::Span<const zetasql::ASTExpression*
996
996
*output = expr_list;
997
997
return base::Status::OK ();
998
998
}
999
+
999
1000
base::Status ConvertFrameBound (const zetasql::ASTWindowFrameExpr* window_frame_expr, node::NodeManager* node_manager,
1000
1001
node::FrameBound** output) {
1001
1002
if (nullptr == window_frame_expr) {
@@ -1042,12 +1043,14 @@ base::Status ConvertFrameBound(const zetasql::ASTWindowFrameExpr* window_frame_e
1042
1043
}
1043
1044
return base::Status::OK ();
1044
1045
}
1046
+
1045
1047
base::Status ConvertFrameNode (const zetasql::ASTWindowFrame* window_frame, node::NodeManager* node_manager,
1046
1048
node::FrameNode** output) {
1047
1049
if (nullptr == window_frame) {
1048
1050
*output = nullptr ;
1049
1051
return base::Status::OK ();
1050
1052
}
1053
+
1051
1054
base::Status status;
1052
1055
node::FrameType frame_type;
1053
1056
switch (window_frame->frame_unit ()) {
@@ -1069,19 +1072,24 @@ base::Status ConvertFrameNode(const zetasql::ASTWindowFrame* window_frame, node:
1069
1072
return status;
1070
1073
}
1071
1074
}
1075
+
1072
1076
node::FrameBound* start = nullptr ;
1073
1077
node::FrameBound* end = nullptr ;
1074
1078
CHECK_TRUE (nullptr != window_frame->start_expr (), common::kSqlAstError , " Un-support window frame with null start" )
1075
1079
CHECK_TRUE (nullptr != window_frame->end_expr (), common::kSqlAstError , " Un-support window frame with null end" )
1076
1080
CHECK_STATUS (ConvertFrameBound (window_frame->start_expr (), node_manager, &start))
1077
1081
CHECK_STATUS (ConvertFrameBound (window_frame->end_expr (), node_manager, &end))
1082
+ CHECK_TRUE (nullptr != start, common::kSqlAstError )
1083
+ CHECK_TRUE (nullptr != end, common::kSqlAstError )
1084
+ auto * frame_ext = node_manager->MakeFrameExtent (start, end);
1085
+ CHECK_TRUE (frame_ext->Valid (), common::kSqlAstError ,
1086
+ " The lower bound of a window frame must be less than or equal to the upper bound" );
1087
+
1078
1088
node::ExprNode* frame_max_size = nullptr ;
1079
1089
if (nullptr != window_frame->max_size ()) {
1080
1090
CHECK_STATUS (ConvertExprNode (window_frame->max_size ()->max_size (), node_manager, &frame_max_size))
1081
1091
}
1082
- auto * frame_ext = node_manager->MakeFrameExtent (start, end);
1083
- CHECK_TRUE (frame_ext->Valid (), common::kSqlAstError ,
1084
- " The lower bound of a window frame must be less than or equal to the upper bound" );
1092
+
1085
1093
*output = node_manager->MakeFrameNode (frame_type, frame_ext, frame_max_size);
1086
1094
return base::Status::OK ();
1087
1095
}
0 commit comments