diff options
author | avevad <avevad@yandex-team.com> | 2024-12-11 14:21:36 +0300 |
---|---|---|
committer | Vitaly Isaev <vitalyisaev@ydb.tech> | 2024-12-12 10:12:06 +0000 |
commit | 0f512bb21b67e34519e7f78de3a792091d7760e4 (patch) | |
tree | 860429f764510f9d6366de33a66ea2284f27f77b /yql/essentials/sql/v1/builtin.cpp | |
parent | ab4ac36b6b8137f19724a1c8954d30374d1db47d (diff) | |
download | ydb-0f512bb21b67e34519e7f78de3a792091d7760e4.tar.gz |
YQL-19123 Move default argument in VisitOrDefault
Change order of arguments in VisitOrDefault
commit_hash:60f1e45096fa62bca6c999fb14abf81754f51e1a
Diffstat (limited to 'yql/essentials/sql/v1/builtin.cpp')
-rw-r--r-- | yql/essentials/sql/v1/builtin.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/yql/essentials/sql/v1/builtin.cpp b/yql/essentials/sql/v1/builtin.cpp index a4bec63066..b7d29303cd 100644 --- a/yql/essentials/sql/v1/builtin.cpp +++ b/yql/essentials/sql/v1/builtin.cpp @@ -3731,16 +3731,20 @@ TNodePtr BuildBuiltinFunc(TContext& ctx, TPosition pos, TString name, const TVec dflt = positional.GetTupleElement(positional.GetTupleSize() - 1); } } else { + size_t minArgs = withDefault ? 2 : 1; + if (args.size() < minArgs) { + return new TInvalidBuiltin(pos, TStringBuilder() << name + << " requires at least " << minArgs << " positional arguments"); + } variant = args[0]; - size_t defaultSuffix = withDefault ? 1 : 0; - labels.reserve(args.size() - 1 - defaultSuffix); - handlers.reserve(args.size() - 1 - defaultSuffix); - for (size_t idx = 0; idx + 1 < args.size() - defaultSuffix; idx++) { + labels.reserve(args.size() - minArgs); + handlers.reserve(args.size() - minArgs); + for (size_t idx = 0; idx < args.size() - minArgs; idx++) { labels.push_back(BuildQuotedAtom(pos, ToString(idx))); - handlers.push_back(args[idx + 1]); + handlers.push_back(args[minArgs + idx]); } if (withDefault) { - dflt = args.back(); + dflt = args[1]; } } TVector<TNodePtr> resultArgs; |