aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Neporada <aneporada@ydb.tech>2024-02-16 15:26:09 +0300
committerGitHub <noreply@github.com>2024-02-16 15:26:09 +0300
commit5553401041960223e9f7a48398657ff26077aa65 (patch)
treeeb19c874bf7b3bf2ff025cb2ec12502ed0a38fae
parent98f2f64353081f6e236b560c292cf0f0de68fa51 (diff)
downloadydb-5553401041960223e9f7a48398657ff26077aa65.tar.gz
[YQL-17818] Fix error handling in SessionWindow (#1988)
-rw-r--r--ydb/library/yql/sql/v1/builtin.cpp5
-rw-r--r--ydb/library/yql/sql/v1/sql_ut.cpp16
2 files changed, 21 insertions, 0 deletions
diff --git a/ydb/library/yql/sql/v1/builtin.cpp b/ydb/library/yql/sql/v1/builtin.cpp
index fecbdebcbb..a24dcb1dc9 100644
--- a/ydb/library/yql/sql/v1/builtin.cpp
+++ b/ydb/library/yql/sql/v1/builtin.cpp
@@ -2097,6 +2097,11 @@ private:
}
}
+ 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) {
diff --git a/ydb/library/yql/sql/v1/sql_ut.cpp b/ydb/library/yql/sql/v1/sql_ut.cpp
index d640235bf2..78a05a85c1 100644
--- a/ydb/library/yql/sql/v1/sql_ut.cpp
+++ b/ydb/library/yql/sql/v1/sql_ut.cpp
@@ -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) {