Skip to content

Commit

Permalink
[YQL-17818] Fix error handling in SessionWindow (#1988)
Browse files Browse the repository at this point in the history
  • Loading branch information
nepal authored Feb 16, 2024
1 parent 98f2f64 commit 5553401
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ydb/library/yql/sql/v1/builtin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2097,6 +2097,11 @@ class TSessionStart final : public INode {
}
}

if (sessionWindow->HasState(ENodeState::Failed)) {
return false;
}

YQL_ENSURE(sessionWindow->HasState(ENodeState::Initialized));
YQL_ENSURE(sessionWindow->GetLabel());
Node = Y("Member", "row", BuildQuotedAtom(Pos, sessionWindow->GetLabel()));
if (OverWindow) {
Expand Down
16 changes: 16 additions & 0 deletions ydb/library/yql/sql/v1/sql_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4375,6 +4375,22 @@ select FormatType($f());
UNIT_ASSERT_NO_DIFF(Err2Str(res),
"<main>:1:15: Error: Selecting data from monitoring source is not supported\n");
}

Y_UNIT_TEST(SessionStartAndSessionStateShouldSurviveSessionWindowArgsError){
TString query = R"(
$init = ($_row) -> (min(1, 2)); -- error: aggregation func min() can not be used here
$calculate = ($_row, $_state) -> (1);
$update = ($_row, $_state) -> (2);
SELECT
SessionStart() over w as session_start,
SessionState() over w as session_state,
FROM plato.Input as t
WINDOW w AS (
PARTITION BY user, SessionWindow(ts + 1, $init, $update, $calculate)
)
)";
ExpectFailWithError(query, "<main>:2:33: Error: Aggregation function Min requires exactly 1 argument(s), given: 2\n");
}
}

void CheckUnused(const TString& req, const TString& symbol, unsigned row, unsigned col) {
Expand Down

0 comments on commit 5553401

Please sign in to comment.