aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraneporada <aneporada@yandex-team.ru>2022-03-05 01:20:53 +0300
committeraneporada <aneporada@yandex-team.ru>2022-03-05 01:20:53 +0300
commitcb1bde724f66cf9674d898ed30e28275f8174a81 (patch)
tree43dab09777bf3b7ceb76e4cd02a9b6997956beb4
parent17e039781a0a6725c45a1bd58dd91f088c5b7620 (diff)
downloadydb-cb1bde724f66cf9674d898ed30e28275f8174a81.tar.gz
[YQL-10265] Improve frame validation
ref:96e25def267e496f2222b87d57dac3389806e686
-rw-r--r--ydb/library/yql/core/yql_opt_window.cpp14
-rw-r--r--ydb/library/yql/core/yql_opt_window.h6
2 files changed, 17 insertions, 3 deletions
diff --git a/ydb/library/yql/core/yql_opt_window.cpp b/ydb/library/yql/core/yql_opt_window.cpp
index aebe6e901a..e85982c21f 100644
--- a/ydb/library/yql/core/yql_opt_window.cpp
+++ b/ydb/library/yql/core/yql_opt_window.cpp
@@ -2568,6 +2568,10 @@ TMaybe<TWindowFrameSettings> TWindowFrameSettings::TryParse(const TExprNode& nod
auto type = fb->Head().Content();
if (type == "currentRow") {
if (fb->ChildrenSize() == 1) {
+ if (!node.IsCallable("WinOnRange")) {
+ ctx.AddError(TIssue(ctx.GetPosition(fb->Pos()), TStringBuilder() << "currentRow should only be used for RANGE"));
+ return {};
+ }
frameBound = fb;
continue;
}
@@ -2699,6 +2703,16 @@ TMaybe<i32> TWindowFrameSettings::GetLastOffset() const {
return LastOffset;
}
+TCoFrameBound TWindowFrameSettings::GetFirst() const {
+ YQL_ENSURE(First);
+ return TCoFrameBound(First);
+}
+
+TCoFrameBound TWindowFrameSettings::GetLast() const {
+ YQL_ENSURE(Last);
+ return TCoFrameBound(Last);
+}
+
TExprNode::TPtr ZipWithSessionParamsLambda(TPositionHandle pos, const TExprNode::TPtr& partitionKeySelector,
const TExprNode::TPtr& sessionKeySelector, const TExprNode::TPtr& sessionInit,
const TExprNode::TPtr& sessionUpdate, TExprContext& ctx)
diff --git a/ydb/library/yql/core/yql_opt_window.h b/ydb/library/yql/core/yql_opt_window.h
index c0c7d8fa69..6e51a6c794 100644
--- a/ydb/library/yql/core/yql_opt_window.h
+++ b/ydb/library/yql/core/yql_opt_window.h
@@ -29,8 +29,8 @@ public:
TMaybe<i32> GetFirstOffset() const;
TMaybe<i32> GetLastOffset() const;
- TCoFrameBound GetFirst(bool& isPreceding) const;
- TCoFrameBound GetLast(bool& isPreceding) const;
+ TCoFrameBound GetFirst() const;
+ TCoFrameBound GetLast() const;
bool IsNonEmpty() const { return NeverEmpty; }
bool IsCompact() const { return Compact; }
@@ -41,7 +41,7 @@ private:
TMaybe<i32> FirstOffset;
TExprNode::TPtr Last;
TMaybe<i32> LastOffset;
- bool NeverEmpty = true;
+ bool NeverEmpty = false;
bool Compact = false;
};