@@ -996,6 +996,7 @@ base::Status ConvertExprNodeList(const absl::Span<const zetasql::ASTExpression*
996996 *output = expr_list;
997997 return base::Status::OK ();
998998}
999+
9991000base::Status ConvertFrameBound (const zetasql::ASTWindowFrameExpr* window_frame_expr, node::NodeManager* node_manager,
10001001 node::FrameBound** output) {
10011002 if (nullptr == window_frame_expr) {
@@ -1042,12 +1043,14 @@ base::Status ConvertFrameBound(const zetasql::ASTWindowFrameExpr* window_frame_e
10421043 }
10431044 return base::Status::OK ();
10441045}
1046+
10451047base::Status ConvertFrameNode (const zetasql::ASTWindowFrame* window_frame, node::NodeManager* node_manager,
10461048 node::FrameNode** output) {
10471049 if (nullptr == window_frame) {
10481050 *output = nullptr ;
10491051 return base::Status::OK ();
10501052 }
1053+
10511054 base::Status status;
10521055 node::FrameType frame_type;
10531056 switch (window_frame->frame_unit ()) {
@@ -1069,19 +1072,24 @@ base::Status ConvertFrameNode(const zetasql::ASTWindowFrame* window_frame, node:
10691072 return status;
10701073 }
10711074 }
1075+
10721076 node::FrameBound* start = nullptr ;
10731077 node::FrameBound* end = nullptr ;
10741078 CHECK_TRUE (nullptr != window_frame->start_expr (), common::kSqlAstError , " Un-support window frame with null start" )
10751079 CHECK_TRUE (nullptr != window_frame->end_expr (), common::kSqlAstError , " Un-support window frame with null end" )
10761080 CHECK_STATUS (ConvertFrameBound (window_frame->start_expr (), node_manager, &start))
10771081 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+
10781088 node::ExprNode* frame_max_size = nullptr ;
10791089 if (nullptr != window_frame->max_size ()) {
10801090 CHECK_STATUS (ConvertExprNode (window_frame->max_size ()->max_size (), node_manager, &frame_max_size))
10811091 }
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+
10851093 *output = node_manager->MakeFrameNode (frame_type, frame_ext, frame_max_size);
10861094 return base::Status::OK ();
10871095}
0 commit comments