summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/node.cpp
diff options
context:
space:
mode:
authorvitya-smirnov <[email protected]>2025-10-07 09:34:39 +0300
committervitya-smirnov <[email protected]>2025-10-07 09:52:14 +0300
commitbabe7533f18c11be1f8a195ed2324d2d9a89436a (patch)
tree45b7627141bf5a52b45a3d61fd1fbdd564bb8dd9 /yql/essentials/sql/v1/node.cpp
parent8fe7cfe254fde2772477a8933a163b5f303716b4 (diff)
YQL-20086 sql/v1
commit_hash:55bc611cdaa0d8a0fc3c4c7708ed9f17cc4976cf
Diffstat (limited to 'yql/essentials/sql/v1/node.cpp')
-rw-r--r--yql/essentials/sql/v1/node.cpp246
1 files changed, 129 insertions, 117 deletions
diff --git a/yql/essentials/sql/v1/node.cpp b/yql/essentials/sql/v1/node.cpp
index 3fc4836e2aa..748dac521eb 100644
--- a/yql/essentials/sql/v1/node.cpp
+++ b/yql/essentials/sql/v1/node.cpp
@@ -23,7 +23,8 @@ namespace NSQLTranslationV1 {
TString ErrorDistinctWithoutCorrelation(const TString& column) {
return TStringBuilder() << "DISTINCT columns for JOIN in SELECT should have table aliases (correlation name),"
- " add it if necessary to FROM section over 'AS <alias>' keyword and put it like '<alias>." << column << "'";
+ " add it if necessary to FROM section over 'AS <alias>' keyword and put it like '<alias>."
+ << column << "'";
}
TString ErrorDistinctByGroupKey(const TString& column) {
@@ -38,7 +39,7 @@ TTopicRef::TTopicRef(const TString& refName, const TDeferredAtom& cluster, TNode
}
TColumnSchema::TColumnSchema(TPosition pos, const TString& name, const TNodePtr& type, bool nullable,
- TVector<TIdentifier> families, bool serial, TNodePtr defaultExpr, ETypeOfChange typeOfChange)
+ TVector<TIdentifier> families, bool serial, TNodePtr defaultExpr, ETypeOfChange typeOfChange)
: Pos(pos)
, Name(name)
, Type(type)
@@ -149,7 +150,7 @@ INode::TPtr INode::ApplyUnaryOp(TContext& ctx, TPosition pos, const TString& opN
if (IsNull()) {
return BuildLiteralNull(pos);
}
- return new TCallNodeImpl(pos, opName, { Clone() });
+ return new TCallNodeImpl(pos, opName, {Clone()});
}
bool INode::IsAsterisk() const {
@@ -417,7 +418,7 @@ void INode::PrecacheState() const {
/// Not work right now! It's better use Init at first, because some kind of update depend on it
/// \todo turn on and remove all issues
- //Y_DEBUG_ABORT_UNLESS(State.Test(ENodeState::Initialized));
+ // Y_DEBUG_ABORT_UNLESS(State.Test(ENodeState::Initialized));
if (State_.Test(ENodeState::Precached)) {
return;
}
@@ -729,7 +730,7 @@ TAstListNode::~TAstListNode()
}
bool TAstListNode::DoInit(TContext& ctx, ISource* src) {
- for (auto& node: Nodes_) {
+ for (auto& node : Nodes_) {
if (!node->Init(ctx, src)) {
return false;
}
@@ -741,7 +742,7 @@ TAstNode* TAstListNode::Translate(TContext& ctx) const {
TSmallVec<TAstNode*> children;
children.reserve(Nodes_.size());
auto listPos = Pos_;
- for (auto& node: Nodes_) {
+ for (auto& node : Nodes_) {
if (node) {
auto astNode = node->Translate(ctx);
if (!astNode) {
@@ -765,10 +766,10 @@ void TAstListNode::UpdateStateByListNodes(const TVector<TNodePtr>& nodes) const
};
std::array<ENodeState, 3> checkStates = {{ENodeState::Aggregated, ENodeState::AggregationKey, ENodeState::OverWindow}};
std::map<ENodeState, TAttributesFlags> flags;
- for (auto& node: nodes) {
+ for (auto& node : nodes) {
const bool isNodeConst = node->IsConstant();
const bool isNodeMaybeConst = node->MaybeConstant();
- for (auto state: checkStates) {
+ for (auto state : checkStates) {
if (node->HasState(state)) {
flags[state].Has = true;
} else if (!isNodeConst && !isNodeMaybeConst) {
@@ -781,7 +782,7 @@ void TAstListNode::UpdateStateByListNodes(const TVector<TNodePtr>& nodes) const
}
}
State_.Set(ENodeState::Const, isConst);
- for (auto& flag: flags) {
+ for (auto& flag : flags) {
State_.Set(flag.first, flag.second.Has && flag.second.All);
}
State_.Set(ENodeState::MaybeConst, !isConst && AllOf(nodes, [](const auto& node) { return node->IsConstant() || node->MaybeConstant(); }));
@@ -809,7 +810,7 @@ TAstListNode::TAstListNode(TPosition pos, TVector<TNodePtr>&& nodes)
: INode(pos)
, Nodes_(std::move(nodes))
{
- for (const auto& node: Nodes_) {
+ for (const auto& node : Nodes_) {
YQL_ENSURE(node, "Null ptr passed as list element");
}
}
@@ -826,12 +827,13 @@ void TAstListNode::DoAdd(TNodePtr node) {
TAstListNodeImpl::TAstListNodeImpl(TPosition pos)
: TAstListNode(pos)
-{}
+{
+}
TAstListNodeImpl::TAstListNodeImpl(TPosition pos, TVector<TNodePtr> nodes)
: TAstListNode(pos)
{
- for (const auto& node: nodes) {
+ for (const auto& node : nodes) {
YQL_ENSURE(node, "Null ptr passed as list element");
}
Nodes_.swap(nodes);
@@ -854,7 +856,7 @@ TCallNode::TCallNode(TPosition pos, const TString& opName, i32 minArgs, i32 maxA
, MaxArgs_(maxArgs)
, Args_(args)
{
- for (const auto& arg: Args_) {
+ for (const auto& arg : Args_) {
YQL_ENSURE(arg, "Null ptr passed as call argument");
}
}
@@ -863,9 +865,9 @@ TString TCallNode::GetOpName() const {
return OpName_;
}
-const TString* DeriveCommonSourceName(const TVector<TNodePtr> &nodes) {
+const TString* DeriveCommonSourceName(const TVector<TNodePtr>& nodes) {
const TString* name = nullptr;
- for (auto& node: nodes) {
+ for (auto& node : nodes) {
auto n = node->GetSourceName();
if (!n) {
continue;
@@ -878,7 +880,6 @@ const TString* DeriveCommonSourceName(const TVector<TNodePtr> &nodes) {
return name;
}
-
const TString* TCallNode::GetSourceName() const {
return DeriveCommonSourceName(Args_);
}
@@ -933,7 +934,7 @@ bool TCallNode::DoInit(TContext& ctx, ISource* src) {
}
bool hasError = false;
- for (auto& arg: Args_) {
+ for (auto& arg : Args_) {
if (!arg->Init(ctx, src)) {
hasError = true;
continue;
@@ -945,7 +946,7 @@ bool TCallNode::DoInit(TContext& ctx, ISource* src) {
}
Nodes_.push_back(BuildAtom(Pos_, OpName_,
- OpName_.cend() == std::find_if_not(OpName_.cbegin(), OpName_.cend(), [](char c) { return bool(std::isalnum(c)); }) ? TNodeFlags::Default : TNodeFlags::ArbitraryContent));
+ OpName_.cend() == std::find_if_not(OpName_.cbegin(), OpName_.cend(), [](char c) { return bool(std::isalnum(c)); }) ? TNodeFlags::Default : TNodeFlags::ArbitraryContent));
Nodes_.insert(Nodes_.end(), Args_.begin(), Args_.end());
return true;
}
@@ -960,11 +961,13 @@ const TCallNode* TCallNode::GetCallNode() const {
TCallNodeImpl::TCallNodeImpl(TPosition pos, const TString& opName, i32 minArgs, i32 maxArgs, const TVector<TNodePtr>& args)
: TCallNode(pos, opName, minArgs, maxArgs, args)
-{}
+{
+}
TCallNodeImpl::TCallNodeImpl(TPosition pos, const TString& opName, const TVector<TNodePtr>& args)
: TCallNode(pos, opName, args.size(), args.size(), args)
-{}
+{
+}
TCallNode::TPtr TCallNodeImpl::DoClone() const {
return new TCallNodeImpl(GetPos(), OpName_, MinArgs_, MaxArgs_, CloneContainer(Args_));
@@ -972,7 +975,8 @@ TCallNode::TPtr TCallNodeImpl::DoClone() const {
TFuncNodeImpl::TFuncNodeImpl(TPosition pos, const TString& opName)
: TCallNode(pos, opName, 0, 0, {})
-{}
+{
+}
TCallNode::TPtr TFuncNodeImpl::DoClone() const {
return new TFuncNodeImpl(GetPos(), OpName_);
@@ -985,12 +989,14 @@ const TString* TFuncNodeImpl::FuncName() const {
TCallNodeDepArgs::TCallNodeDepArgs(ui32 reqArgsCount, TPosition pos, const TString& opName, i32 minArgs, i32 maxArgs, const TVector<TNodePtr>& args)
: TCallNode(pos, opName, minArgs, maxArgs, args)
, ReqArgsCount_(reqArgsCount)
-{}
+{
+}
TCallNodeDepArgs::TCallNodeDepArgs(ui32 reqArgsCount, TPosition pos, const TString& opName, const TVector<TNodePtr>& args)
: TCallNode(pos, opName, args.size(), args.size(), args)
, ReqArgsCount_(reqArgsCount)
-{}
+{
+}
TCallNode::TPtr TCallNodeDepArgs::DoClone() const {
return new TCallNodeDepArgs(ReqArgsCount_, GetPos(), OpName_, MinArgs_, MaxArgs_, CloneContainer(Args_));
@@ -1013,11 +1019,13 @@ INode::TPtr TCallDirectRow::DoClone() const {
TCallDirectRow::TCallDirectRow(TPosition pos, const TString& opName, i32 minArgs, i32 maxArgs, const TVector<TNodePtr>& args)
: TCallNode(pos, opName, minArgs, maxArgs, args)
-{}
+{
+}
TCallDirectRow::TCallDirectRow(TPosition pos, const TString& opName, const TVector<TNodePtr>& args)
: TCallNode(pos, opName, 0, 0, args)
-{}
+{
+}
bool TCallDirectRow::DoInit(TContext& ctx, ISource* src) {
if (!src || (ctx.CompactNamedExprs && src->IsFake())) {
@@ -1076,7 +1084,7 @@ bool TWinAggrEmulation::DoInit(TContext& ctx, ISource* src) {
INode::TPtr TWinAggrEmulation::WindowSpecFunc(const TPtr& type) const {
auto result = Y(OpName_, type);
- for (const auto& arg: Args_) {
+ for (const auto& arg : Args_) {
result = L(result, arg);
}
return Q(Y(Q(FuncAlias_), result));
@@ -1085,15 +1093,18 @@ INode::TPtr TWinAggrEmulation::WindowSpecFunc(const TPtr& type) const {
TWinAggrEmulation::TWinAggrEmulation(TPosition pos, const TString& opName, i32 minArgs, i32 maxArgs, const TVector<TNodePtr>& args)
: TCallNode(pos, opName, minArgs, maxArgs, args)
, FuncAlias_(opName)
-{}
+{
+}
TWinRowNumber::TWinRowNumber(TPosition pos, const TString& opName, i32 minArgs, i32 maxArgs, const TVector<TNodePtr>& args)
: TWinAggrEmulation(pos, opName, minArgs, maxArgs, args)
-{}
+{
+}
TWinCumeDist::TWinCumeDist(TPosition pos, const TString& opName, i32 minArgs, i32 maxArgs, const TVector<TNodePtr>& args)
: TWinAggrEmulation(pos, opName, minArgs, maxArgs, args)
-{}
+{
+}
bool TWinCumeDist::DoInit(TContext& ctx, ISource* src) {
if (!ValidateArguments(ctx)) {
@@ -1103,7 +1114,7 @@ bool TWinCumeDist::DoInit(TContext& ctx, ISource* src) {
YQL_ENSURE(Args_.size() == 0);
TVector<TNodePtr> optionsElements;
if (ctx.AnsiCurrentRow) {
- optionsElements.push_back(BuildTuple(Pos_, { BuildQuotedAtom(Pos_, "ansi", NYql::TNodeFlags::Default) }));
+ optionsElements.push_back(BuildTuple(Pos_, {BuildQuotedAtom(Pos_, "ansi", NYql::TNodeFlags::Default)}));
}
Args_.push_back(BuildTuple(Pos_, optionsElements));
@@ -1135,7 +1146,8 @@ bool TWinNTile::DoInit(TContext& ctx, ISource* src) {
TWinLeadLag::TWinLeadLag(TPosition pos, const TString& opName, i32 minArgs, i32 maxArgs, const TVector<TNodePtr>& args)
: TWinAggrEmulation(pos, opName, minArgs, maxArgs, args)
-{}
+{
+}
bool TWinLeadLag::DoInit(TContext& ctx, ISource* src) {
if (Args_.size() >= 2) {
@@ -1156,11 +1168,10 @@ bool TWinLeadLag::DoInit(TContext& ctx, ISource* src) {
TWinRank::TWinRank(TPosition pos, const TString& opName, i32 minArgs, i32 maxArgs, const TVector<TNodePtr>& args)
: TWinAggrEmulation(pos, opName, minArgs, maxArgs, args)
{
-
}
bool TExternalFunctionConfig::DoInit(TContext& ctx, ISource* src) {
- for (auto& param: Config_) {
+ for (auto& param : Config_) {
auto paramName = Y(BuildQuotedAtom(Pos_, param.first));
if (!param.second->Init(ctx, src)) {
return false;
@@ -1204,21 +1215,21 @@ bool TWinRank::DoInit(TContext& ctx, ISource* src) {
if (orderSpec.empty()) {
if (Args_.empty()) {
if (!ctx.Warning(GetPos(), TIssuesIds::YQL_RANK_WITHOUT_ORDER_BY, [&](auto& out) {
- out << OpName_ << "() is used with unordered window - all rows will be considered equal to each other";
- })) {
+ out << OpName_ << "() is used with unordered window - all rows will be considered equal to each other";
+ })) {
return false;
}
} else {
if (!ctx.Warning(GetPos(), TIssuesIds::YQL_RANK_WITHOUT_ORDER_BY, [&](auto& out) {
- out << OpName_ << "(<expression>) is used with unordered window - the result is likely to be undefined";
- })) {
+ out << OpName_ << "(<expression>) is used with unordered window - the result is likely to be undefined";
+ })) {
return false;
}
}
}
if (Args_.empty()) {
- for (const auto& spec: orderSpec) {
+ for (const auto& spec : orderSpec) {
Args_.push_back(spec->Clone()->OrderExpr);
}
@@ -1231,9 +1242,9 @@ bool TWinRank::DoInit(TContext& ctx, ISource* src) {
TVector<TNodePtr> optionsElements;
if (!ctx.AnsiRankForNullableKeys.Defined()) {
- optionsElements.push_back(BuildTuple(Pos_, { BuildQuotedAtom(Pos_, "warnNoAnsi", NYql::TNodeFlags::Default) }));
+ optionsElements.push_back(BuildTuple(Pos_, {BuildQuotedAtom(Pos_, "warnNoAnsi", NYql::TNodeFlags::Default)}));
} else if (*ctx.AnsiRankForNullableKeys) {
- optionsElements.push_back(BuildTuple(Pos_, { BuildQuotedAtom(Pos_, "ansi", NYql::TNodeFlags::Default) }));
+ optionsElements.push_back(BuildTuple(Pos_, {BuildQuotedAtom(Pos_, "ansi", NYql::TNodeFlags::Default)}));
}
Args_.push_back(BuildTuple(Pos_, optionsElements));
@@ -1270,7 +1281,6 @@ TNodePtr BuildQuotedAtom(TPosition pos, const TString& content, ui32 flags) {
return new TQuotedAtomNode(pos, content, flags);
}
-
TNodePtr ITableKeys::AddView(TNodePtr key, const TViewDescription& view) {
if (view.PrimaryFlag) {
return L(key, Q(Y(Q("primary_view"))));
@@ -1386,7 +1396,7 @@ bool MaybeAutogenerated(const TString& name) {
}
bool MatchDotSuffix(const TSet<TString>& columns, const TString& column) {
- for (const auto& col: columns) {
+ for (const auto& col : columns) {
const auto pos = col.find_first_of(".");
if (pos == TString::npos) {
continue;
@@ -1398,7 +1408,7 @@ bool MatchDotSuffix(const TSet<TString>& columns, const TString& column) {
return false;
}
-}
+} // namespace
bool TColumns::IsColumnPossible(TContext& ctx, const TString& name) const {
if (All || Real.contains(name) || Artificial.contains(name)) {
@@ -1420,7 +1430,7 @@ bool TColumns::IsColumnPossible(TContext& ctx, const TString& name) const {
return true;
}
}
- for (const auto& real: Real) {
+ for (const auto& real : Real) {
const auto pos = real.find_first_of("*");
if (pos == TString::npos) {
continue;
@@ -1479,7 +1489,7 @@ TWindowSpecificationPtr TWindowSpecification::Clone() const {
TWinSpecs CloneContainer(const TWinSpecs& specs) {
TWinSpecs newSpecs;
- for (auto cur: specs) {
+ for (auto cur : specs) {
newSpecs.emplace(cur.first, cur.second->Clone());
}
return newSpecs;
@@ -1534,7 +1544,7 @@ TColumnNode* TColumnNode::GetColumnNode() {
return this;
}
-const TColumnNode* TColumnNode::GetColumnNode () const {
+const TColumnNode* TColumnNode::GetColumnNode() const {
return this;
}
@@ -1735,8 +1745,12 @@ void IAggregation::MarkKeyColumnAsGenerated() {
}
IAggregation::IAggregation(TPosition pos, const TString& name, const TString& func, EAggregateMode aggMode)
- : INode(pos), Name_(name), Func_(func), AggMode_(aggMode)
-{}
+ : INode(pos)
+ , Name_(name)
+ , Func_(func)
+ , AggMode_(aggMode)
+{
+}
TAstNode* IAggregation::Translate(TContext& ctx) const {
Y_DEBUG_ABORT_UNLESS(false);
@@ -1749,17 +1763,15 @@ std::pair<TNodePtr, bool> IAggregation::AggregationTraits(const TNodePtr& type,
const auto listType = distinct ? Y("ListType", Y("StructMemberType", Y("ListItemType", type), BuildQuotedAtom(Pos_, DistinctKey_))) : type;
auto apply = GetApply(listType, many, allowAggApply, ctx);
if (!apply) {
- return { nullptr, false };
+ return {nullptr, false};
}
auto wrapped = WrapIfOverState(apply, overState, many, ctx);
if (!wrapped) {
- return { nullptr, false };
+ return {nullptr, false};
}
- return { distinct ?
- Q(Y(Q(Name_), wrapped, BuildQuotedAtom(Pos_, DistinctKey_))) :
- Q(Y(Q(Name_), wrapped)), true };
+ return {distinct ? Q(Y(Q(Name_), wrapped, BuildQuotedAtom(Pos_, DistinctKey_))) : Q(Y(Q(Name_), wrapped)), true};
}
TNodePtr IAggregation::WrapIfOverState(const TNodePtr& input, bool overState, bool many, TContext& ctx) const {
@@ -1829,7 +1841,7 @@ TString UnescapeAnsiQuoted(const TString& str) {
return result;
}
-enum class EStringContentMode : int {
+enum class EStringContentMode: int {
Default = 0,
AnsiIdent,
TypedStringLiteral,
@@ -1879,8 +1891,8 @@ StringContentInternal(TContext& ctx, TPosition pos, const TString& input, EStrin
} else {
if (ctx.Scoped->WarnUntypedStringLiterals) {
if (!ctx.Warning(pos, TIssuesIds::YQL_UNTYPED_STRING_LITERALS, [](auto& out) {
- out << "Please add suffix u for Utf8 strings or s for arbitrary binary strings";
- })) {
+ out << "Please add suffix u for Utf8 strings or s for arbitrary binary strings";
+ })) {
return {};
}
}
@@ -1941,12 +1953,13 @@ TMaybe<TStringContent> StringContent(TContext& ctx, TPosition pos, const TString
TMaybe<TStringContent> StringContentOrIdContent(TContext& ctx, TPosition pos, const TString& input) {
return StringContentInternal(ctx, pos, input,
- (ctx.AnsiQuotedIdentifiers && input.StartsWith('"'))? EStringContentMode::AnsiIdent : EStringContentMode::Default);
+ (ctx.AnsiQuotedIdentifiers && input.StartsWith('"')) ? EStringContentMode::AnsiIdent : EStringContentMode::Default);
}
TTtlSettings::TTierSettings::TTierSettings(const TNodePtr& evictionDelay, const std::optional<TIdentifier>& storageName)
: EvictionDelay(evictionDelay)
- , StorageName(storageName) {
+ , StorageName(storageName)
+{
}
TTtlSettings::TTtlSettings(const TIdentifier& columnName, const std::vector<TTierSettings>& tiers, const TMaybe<EUnit>& columnUnit)
@@ -2006,7 +2019,6 @@ TString IdContentFromString(TContext& ctx, const TString& str) {
return parsed->Content;
}
-
namespace {
class TInvalidLiteralNode final: public INode {
public:
@@ -2031,7 +2043,7 @@ public:
}
};
-}
+} // namespace
TLiteralNode::TLiteralNode(TPosition pos, bool isNull)
: TAstListNode(pos)
@@ -2109,18 +2121,19 @@ TNodePtr TLiteralNode::DoClone() const {
return res;
}
-template<typename T>
+template <typename T>
TLiteralNumberNode<T>::TLiteralNumberNode(TPosition pos, const TString& type, const TString& value, bool implicitType)
: TLiteralNode(pos, type, value)
, ImplicitType_(implicitType)
-{}
+{
+}
-template<typename T>
+template <typename T>
TNodePtr TLiteralNumberNode<T>::DoClone() const {
return new TLiteralNumberNode<T>(Pos_, Type_, Value_, ImplicitType_);
}
-template<typename T>
+template <typename T>
bool TLiteralNumberNode<T>::DoInit(TContext& ctx, ISource* src) {
Y_UNUSED(src);
T val;
@@ -2131,12 +2144,12 @@ bool TLiteralNumberNode<T>::DoInit(TContext& ctx, ISource* src) {
return true;
}
-template<typename T>
+template <typename T>
bool TLiteralNumberNode<T>::IsIntegerLiteral() const {
return std::numeric_limits<T>::is_integer;
}
-template<typename T>
+template <typename T>
TNodePtr TLiteralNumberNode<T>::ApplyUnaryOp(TContext& ctx, TPosition pos, const TString& opName) const {
YQL_ENSURE(!Value_.empty());
if (opName == "Minus" && IsIntegerLiteral() && Value_[0] != '-') {
@@ -2167,7 +2180,6 @@ TNodePtr TLiteralNumberNode<T>::ApplyUnaryOp(TContext& ctx, TPosition pos, const
return INode::ApplyUnaryOp(ctx, pos, opName);
}
-
template class TLiteralNumberNode<i32>;
template class TLiteralNumberNode<i64>;
template class TLiteralNumberNode<ui32>;
@@ -2217,7 +2229,6 @@ TMaybe<TExprOrIdent> BuildLiteralTypedSmartStringOrId(TContext& ctx, const TStri
return result;
}
-
TNodePtr BuildLiteralRawString(TPosition pos, const TString& value, bool isUtf8) {
return new TLiteralNode(pos, isUtf8 ? "Utf8" : "String", value);
}
@@ -2227,8 +2238,9 @@ TNodePtr BuildLiteralBool(TPosition pos, bool value) {
}
TAsteriskNode::TAsteriskNode(TPosition pos)
- : INode(pos)
-{}
+ : INode(pos)
+{
+}
bool TAsteriskNode::IsAsterisk() const {
return true;
@@ -2251,7 +2263,8 @@ TNodePtr BuildEmptyAction(TPosition pos) {
}
TDeferredAtom::TDeferredAtom()
-{}
+{
+}
TDeferredAtom::TDeferredAtom(TPosition pos, const TString& str)
{
@@ -2299,7 +2312,8 @@ bool TDeferredAtom::HasNode() const {
TTupleNode::TTupleNode(TPosition pos, const TVector<TNodePtr>& exprs)
: TAstListNode(pos)
, Exprs_(exprs)
-{}
+{
+}
bool TTupleNode::IsEmpty() const {
return Exprs_.empty();
@@ -2319,7 +2333,7 @@ const TTupleNode* TTupleNode::GetTupleNode() const {
bool TTupleNode::DoInit(TContext& ctx, ISource* src) {
auto node(Y());
- for (auto& expr: Exprs_) {
+ for (auto& expr : Exprs_) {
if (expr->GetLabel()) {
ctx.Error(expr->GetPos()) << "Tuple does not allow named members";
return false;
@@ -2424,7 +2438,8 @@ TNodePtr BuildOrderedStructure(TPosition pos, const TVector<TNodePtr>& exprsUnla
TListOfNamedNodes::TListOfNamedNodes(TPosition pos, TVector<TNodePtr>&& exprs)
: INode(pos)
, Exprs_(std::move(exprs))
-{}
+{
+}
TVector<TNodePtr>* TListOfNamedNodes::ContentListPtr() {
return &Exprs_;
@@ -2450,8 +2465,9 @@ TNodePtr BuildListOfNamedNodes(TPosition pos, TVector<TNodePtr>&& exprs) {
return new TListOfNamedNodes(pos, std::move(exprs));
}
-TArgPlaceholderNode::TArgPlaceholderNode(TPosition pos, const TString &name) :
- INode(pos),
+TArgPlaceholderNode::TArgPlaceholderNode(TPosition pos, const TString& name)
+ : INode(pos)
+ ,
Name_(name)
{
}
@@ -2564,7 +2580,7 @@ public:
if (!expr->Init(ctx, src)) {
return false;
}
- for (auto& id: Ids_) {
+ for (auto& id : Ids_) {
if (id.Expr && !id.Expr->Init(ctx, src)) {
return false;
}
@@ -2631,7 +2647,7 @@ public:
YQL_ENSURE(!Node_, "TAccessNode::Clone: Node should not be initialized");
TVector<TIdPart> cloneIds;
cloneIds.reserve(Ids_.size());
- for (const auto& id: Ids_) {
+ for (const auto& id : Ids_) {
cloneIds.emplace_back(id.Clone());
}
auto copy = new TAccessNode(Pos_, cloneIds, IsLookup_);
@@ -2796,7 +2812,7 @@ bool WarnIfAliasFromSelectIsUsedInGroupBy(TContext& ctx, const TVector<TNodePtr>
}
bool ValidateAllNodesForAggregation(TContext& ctx, const TVector<TNodePtr>& nodes) {
- for (auto& node: nodes) {
+ for (auto& node : nodes) {
if (!node->HasState(ENodeState::Initialized) || node->IsConstant() || node->MaybeConstant()) {
continue;
}
@@ -2846,6 +2862,7 @@ public:
{
Add("bind", AstNode(module), BuildQuotedAtom(pos, alias));
}
+
private:
TBindNode(const TBindNode& other)
: TAstListNode(other.GetPos())
@@ -2962,7 +2979,7 @@ TNodePtr BuildSimpleType(TContext& ctx, TPosition pos, const TString& typeName,
bool explicitPgType = ctx.GetColumnReferenceState() == EColumnRefState::AsPgType;
auto found = LookupSimpleType(typeName, ctx.FlexibleTypes, explicitPgType);
if (!found) {
- ctx.Error(pos) << "Unknown " << (explicitPgType ? "pg" : "simple") << " type '" << typeName << "'";
+ ctx.Error(pos) << "Unknown " << (explicitPgType ? "pg" : "simple") << " type '" << typeName << "'";
return {};
}
@@ -2983,10 +3000,10 @@ TNodePtr BuildSimpleType(TContext& ctx, TPosition pos, const TString& typeName,
} else {
pgType = type.substr(2);
}
- return new TCallNodeImpl(pos, "PgType", { BuildQuotedAtom(pos, pgType, TNodeFlags::Default) });
+ return new TCallNodeImpl(pos, "PgType", {BuildQuotedAtom(pos, pgType, TNodeFlags::Default)});
}
- return new TCallNodeImpl(pos, "DataType", { BuildQuotedAtom(pos, type, TNodeFlags::Default) });
+ return new TCallNodeImpl(pos, "DataType", {BuildQuotedAtom(pos, type, TNodeFlags::Default)});
}
TString TypeByAlias(const TString& alias, bool normalize) {
@@ -3018,8 +3035,6 @@ TNodePtr BuildIsNullOp(TPosition pos, TNodePtr a) {
return new TCallNodeImpl(pos, "Not", {new TCallNodeImpl(pos, "Exists", {a})});
}
-
-
TUdfNode::TUdfNode(TPosition pos, const TVector<TNodePtr>& args)
: INode(pos)
, Args_(args)
@@ -3089,7 +3104,7 @@ bool TUdfNode::DoInit(TContext& ctx, ISource* src) {
}
if (TStructNode* named_args = Args_[1]->GetStructNode(); named_args) {
- for (const auto &arg: named_args->GetExprs()) {
+ for (const auto& arg : named_args->GetExprs()) {
if (arg->GetLabel() == "TypeConfig") {
if (function->IsScript()) {
ctx.Error() << "Udf: TypeConfig is not supported for script udfs";
@@ -3110,10 +3125,10 @@ bool TUdfNode::DoInit(TContext& ctx, ISource* src) {
ExtraMem_ = MakeAtomFromExpression(Pos_, ctx, arg);
} else if (arg->GetLabel() == "Depends") {
if (!IsBackwardCompatibleFeatureAvailable(ctx.Settings.LangVer,
- NYql::MakeLangVersion(2025,3), ctx.Settings.BackportMode)) {
- ctx.Error() << "Udf: named argument Depends is not available before version 2025.03";
- return false;
- }
+ NYql::MakeLangVersion(2025, 3), ctx.Settings.BackportMode)) {
+ ctx.Error() << "Udf: named argument Depends is not available before version 2025.03";
+ return false;
+ }
Depends_.push_back(arg);
} else {
ctx.Error() << "Udf: unexpected named argument: " << arg->GetLabel();
@@ -3191,7 +3206,6 @@ TNodePtr TUdfNode::DoClone() const {
return new TUdfNode(Pos_, CloneContainer(Args_));
}
-
class TBinaryOpNode final: public TCallNode {
public:
TBinaryOpNode(TPosition pos, const TString& opName, TNodePtr a, TNodePtr b);
@@ -3203,7 +3217,7 @@ public:
};
TBinaryOpNode::TBinaryOpNode(TPosition pos, const TString& opName, TNodePtr a, TNodePtr b)
- : TCallNode(pos, opName, 2, 2, { a, b })
+ : TCallNode(pos, opName, 2, 2, {a, b})
{
}
@@ -3214,18 +3228,17 @@ TNodePtr BuildBinaryOp(TContext& ctx, TPosition pos, const TString& opName, TNod
static const THashSet<TStringBuf> nullSafeOps = {
"IsDistinctFrom", "IsNotDistinctFrom",
- "EqualsIgnoreCase", "StartsWithIgnoreCase", "EndsWithIgnoreCase", "StringContainsIgnoreCase"
- };
+ "EqualsIgnoreCase", "StartsWithIgnoreCase", "EndsWithIgnoreCase", "StringContainsIgnoreCase"};
if (!nullSafeOps.contains(opName)) {
const bool bothArgNull = a->IsNull() && b->IsNull();
- const bool oneArgNull = a->IsNull() || b->IsNull();
+ const bool oneArgNull = a->IsNull() || b->IsNull();
if (bothArgNull || (oneArgNull && opName != "Or" && opName != "And")) {
if (!ctx.Warning(pos, TIssuesIds::YQL_OPERATION_WILL_RETURN_NULL, [&](auto& out) {
- out << "Binary operation "
- << opName.substr(0, opName.size() - 7 * opName.EndsWith("MayWarn"))
- << " will return NULL here";
- })) {
+ out << "Binary operation "
+ << opName.substr(0, opName.size() - 7 * opName.EndsWith("MayWarn"))
+ << " will return NULL here";
+ })) {
return nullptr;
}
}
@@ -3248,7 +3261,8 @@ public:
: INode(pos)
, WindowName_(windowName)
, FuncNode_(node)
- {}
+ {
+ }
TAstNode* Translate(TContext& ctx) const override {
return FuncNode_->Translate(ctx);
@@ -3286,6 +3300,7 @@ public:
INode::CollectPreaggregateExprs(ctx, src, exprs);
}
}
+
protected:
const TString WindowName_;
TNodePtr FuncNode_;
@@ -3295,7 +3310,7 @@ TNodePtr BuildCalcOverWindow(TPosition pos, const TString& windowName, TNodePtr
return new TCalcOverWindow(pos, windowName, call);
}
-template<bool Fast>
+template <bool Fast>
class TYsonOptionsNode final: public INode {
public:
TYsonOptionsNode(TPosition pos, bool autoConvert, bool strict)
@@ -3308,7 +3323,7 @@ public:
autoConvertNode->SetLabel("AutoConvert");
auto strictNode = BuildLiteralBool(pos, strict);
strictNode->SetLabel("Strict");
- Node_ = Y("NamedApply", udf, Q(Y()), BuildStructure(pos, { autoConvertNode, strictNode }));
+ Node_ = Y("NamedApply", udf, Q(Y()), BuildStructure(pos, {autoConvertNode, strictNode}));
}
TAstNode* Translate(TContext& ctx) const override {
@@ -3337,13 +3352,14 @@ protected:
};
TNodePtr BuildYsonOptionsNode(TPosition pos, bool autoConvert, bool strict, bool fastYson) {
- if (fastYson)
+ if (fastYson) {
return new TYsonOptionsNode<true>(pos, autoConvert, strict);
- else
+ } else {
return new TYsonOptionsNode<false>(pos, autoConvert, strict);
+ }
}
-class TDoCall final : public INode {
+class TDoCall final: public INode {
public:
TDoCall(TPosition pos, const TNodePtr& node)
: INode(pos)
@@ -3377,6 +3393,7 @@ public:
Y_DEBUG_ABORT_UNLESS(Node_);
Node_->VisitTree(func, visited);
}
+
private:
TNodePtr Node_;
TSourcePtr FakeSource_;
@@ -3403,7 +3420,7 @@ TNodePtr GroundWithExpr(const TNodePtr& ground, const TNodePtr& expr) {
}
TSourcePtr TryMakeSourceFromExpression(TPosition pos, TContext& ctx, const TString& currService, const TDeferredAtom& currCluster,
- TNodePtr node, const TString& view) {
+ TNodePtr node, const TString& view) {
if (currCluster.Empty()) {
ctx.Error() << "No cluster name given and no default cluster is selected";
return nullptr;
@@ -3421,10 +3438,8 @@ TSourcePtr TryMakeSourceFromExpression(TPosition pos, TContext& ctx, const TStri
return nullptr;
}
- auto wrappedNode = new TAstListNodeImpl(pos, {
- new TAstAtomNodeImpl(pos, "EvaluateAtom", TNodeFlags::Default),
- node
- });
+ auto wrappedNode = new TAstListNodeImpl(pos, {new TAstAtomNodeImpl(pos, "EvaluateAtom", TNodeFlags::Default),
+ node});
TNodePtr tableKey = BuildTableKey(node->GetPos(), currService, currCluster, TDeferredAtom(wrappedNode, ctx), {view});
TTableRef table(ctx.MakeName("table"), currService, currCluster, tableKey);
@@ -3450,10 +3465,8 @@ void MakeTableFromExpression(TPosition pos, TContext& ctx, TNodePtr node, TDefer
node = node->Y("Concat", node->Y("String", node->Q(prefix)), node);
}
- auto wrappedNode = new TAstListNodeImpl(pos, {
- new TAstAtomNodeImpl(pos, "EvaluateAtom", TNodeFlags::Default),
- node
- });
+ auto wrappedNode = new TAstListNodeImpl(pos, {new TAstAtomNodeImpl(pos, "EvaluateAtom", TNodeFlags::Default),
+ node});
table = TDeferredAtom(wrappedNode, ctx);
}
@@ -3467,10 +3480,8 @@ TDeferredAtom MakeAtomFromExpression(TPosition pos, TContext& ctx, TNodePtr node
node = node->Y("Concat", node->Y("String", node->Q(prefix)), node);
}
- auto wrappedNode = new TAstListNodeImpl(pos, {
- new TAstAtomNodeImpl(pos, "EvaluateAtom", TNodeFlags::Default),
- node
- });
+ auto wrappedNode = new TAstListNodeImpl(pos, {new TAstAtomNodeImpl(pos, "EvaluateAtom", TNodeFlags::Default),
+ node});
return TDeferredAtom(wrappedNode, ctx);
}
@@ -3506,6 +3517,7 @@ public:
Y_DEBUG_ABORT_UNLESS(Node_);
Node_->VisitTree(func, visited);
}
+
protected:
TNodePtr Node_;
const size_t EnsureTupleSize_;