aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkniv <kniv@yandex-team.ru>2022-06-01 10:41:11 +0300
committerkniv <kniv@yandex-team.ru>2022-06-01 10:41:11 +0300
commitc4e946f5f69ed19cbb45865bfb5e8ff0ac15be0f (patch)
tree03b5cf02f2614cbf015aaa21ad79153718bc31a4
parent047e759274848e8f522c9dbd3066959a04242f7d (diff)
downloadydb-c4e946f5f69ed19cbb45865bfb5e8ff0ac15be0f.tar.gz
YQL-14865: [LIMIT clause] Allow optional Uint64 values
ref:f0b996488940cb387295e62b5212505b031cc17f
-rw-r--r--ydb/library/yql/core/common_opt/yql_co_simple1.cpp3
-rw-r--r--ydb/library/yql/sql/v1/select.cpp5
2 files changed, 6 insertions, 2 deletions
diff --git a/ydb/library/yql/core/common_opt/yql_co_simple1.cpp b/ydb/library/yql/core/common_opt/yql_co_simple1.cpp
index 6bd7177053..4e9ef778fc 100644
--- a/ydb/library/yql/core/common_opt/yql_co_simple1.cpp
+++ b/ydb/library/yql/core/common_opt/yql_co_simple1.cpp
@@ -3814,6 +3814,9 @@ void RegisterCoSimpleCallables1(TCallableOptimizerMap& map) {
auto res = ctx.NewCallable(node->Tail().Pos(), GetEmptyCollectionName(node->GetTypeAnn()), {ExpandType(node->Pos(), *node->GetTypeAnn(), ctx)});
res = KeepConstraints(res, *node, ctx);
return KeepColumnOrder(res, *node, ctx, *optCtx.Types);
+ } else if (value == std::numeric_limits<ui64>::max()) {
+ YQL_CLOG(DEBUG, Core) << node->Content() << " with " << node->Tail().Content() << " '" << node->Tail().Head().Content();
+ return node->HeadPtr();
}
}
diff --git a/ydb/library/yql/sql/v1/select.cpp b/ydb/library/yql/sql/v1/select.cpp
index f3e7cea6e9..0876b8aebc 100644
--- a/ydb/library/yql/sql/v1/select.cpp
+++ b/ydb/library/yql/sql/v1/select.cpp
@@ -2694,9 +2694,10 @@ public:
{
TNodePtr select(AstNode("select"));
if (skip) {
- select = Y("Skip", select, skip);
+ select = Y("Skip", select, Y("Coalesce", skip, Y("Uint64", Q("0"))));
}
- Add("let", "select", Y("Take", select, take));
+ static const TString uiMax = ::ToString(std::numeric_limits<ui64>::max());
+ Add("let", "select", Y("Take", select, Y("Coalesce", take, Y("Uint64", Q(uiMax)))));
}
TPtr DoClone() const final {