Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case insensivity for pg_catalog tables/cluster, columns. Support of pg_class:relam, and some columns in pg_database & pg_namespace #1893

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/library/yql/ast/yql_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3206,7 +3206,7 @@ ui32 TPgExprType::GetFlags(ui32 typeId) {

const auto& desc = *descPtr;
ui32 ret = TypeHasManyValues | TypeHasOptional;
if (!desc.SendFuncId || !desc.ReceiveFuncId) {
if ((!desc.SendFuncId || !desc.ReceiveFuncId) && (!desc.OutFuncId || !desc.InFuncId)) {
ret |= TypeNonPersistable;
}

Expand Down
21 changes: 21 additions & 0 deletions ydb/library/yql/ast/yql_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <library/cpp/containers/stack_vector/stack_vec.h>
#include <library/cpp/deprecated/enum_codegen/enum_codegen.h>

#include <util/string/ascii.h>
#include <util/string/builder.h>
#include <util/generic/array_ref.h>
#include <util/generic/deque.h>
Expand Down Expand Up @@ -531,6 +532,26 @@ class TStructExprType : public TTypeAnnotationNode {
return it - Items.begin();
}

TMaybe<ui32> FindItemI(const TStringBuf& name) const {
auto strict = FindItem(name);
if (strict) {
return strict;
}

TMaybe<ui32> ret;
for (ui32 i = 0; i < Items.size(); ++i) {
if (AsciiEqualsIgnoreCase(name, Items[i]->GetName())) {
if (ret) {
return Nothing();
}

ret = i;
}
}

return ret;
}

const TTypeAnnotationNode* FindItemType(const TStringBuf& name) const {
const auto it = LowerBound(Items.begin(), Items.end(), name, TItemLess());
if (it == Items.end() || (*it)->GetName() != name) {
Expand Down
22 changes: 11 additions & 11 deletions ydb/library/yql/core/type_ann/type_ann_pg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ IGraphTransformer::TStatus InferPgCommonType(TPositionHandle pos, const TExprNod
{
size_t j = 0;
for (const auto& col : *childColumnOrder) {
auto itemIdx = structType->FindItem(col);
auto itemIdx = structType->FindItemI(col);
YQL_ENSURE(itemIdx);

const auto* type = structType->GetItems()[*itemIdx]->GetItemType();
Expand Down Expand Up @@ -1577,7 +1577,7 @@ bool ScanColumns(TExprNode::TPtr root, TInputs& inputs, const THashSet<TString>&
}
}

auto pos = x.Type->FindItem(node->Tail().Content());
auto pos = x.Type->FindItemI(node->Tail().Content());
if (pos) {
foundAlias = x.Alias;
++matches;
Expand All @@ -1589,7 +1589,7 @@ bool ScanColumns(TExprNode::TPtr root, TInputs& inputs, const THashSet<TString>&
}

if (x.Priority == TInput::External) {
x.UsedExternalColumns.insert(TString(node->Tail().Content()));
x.UsedExternalColumns.insert(TString(x.Type->GetItems()[*pos]->GetName()));
}
}
}
Expand Down Expand Up @@ -1780,12 +1780,12 @@ void AddColumns(const TInputs& inputs, const bool* hasStar, const THashSet<TStri
continue;
}

auto pos = x.Type->FindItem(ref);
auto pos = x.Type->FindItemI(ref);
if (pos) {
auto item = x.Type->GetItems()[*pos];
item = AddAlias(x.Alias, item, ctx);
items.push_back(item);
usedRefs.insert(ref);
usedRefs.insert(TString(item->GetName()));
}
}

Expand All @@ -1795,7 +1795,7 @@ void AddColumns(const TInputs& inputs, const bool* hasStar, const THashSet<TStri
}

for (const auto& ref : qualifiedRefs->find(x.Alias)->second) {
auto pos = x.Type->FindItem(ref);
auto pos = x.Type->FindItemI(ref);
if (pos) {
auto item = x.Type->GetItems()[*pos];
item = AddAlias(x.Alias, item, ctx);
Expand Down Expand Up @@ -1882,12 +1882,12 @@ IGraphTransformer::TStatus RebuildLambdaColumns(const TExprNode::TPtr& root, con
}
}

auto pos = x.Type->FindItem(node->Tail().Content());
auto pos = x.Type->FindItemI(node->Tail().Content());
if (pos) {
return ctx.Expr.Builder(node->Pos())
.Callable("Member")
.Add(0, argNode)
.Atom(1, MakeAliasedColumn(x.Alias, node->Tail().Content()))
.Atom(1, MakeAliasedColumn(x.Alias, x.Type->GetItems()[*pos]->GetName()))
.Seal()
.Build();
}
Expand Down Expand Up @@ -2754,7 +2754,7 @@ bool GatherExtraSortColumns(const TExprNode& data, const TInputs& inputs, TExprN
continue;
}

auto pos = x.Type->FindItem(column);
auto pos = x.Type->FindItemI(column);
if (pos) {
index = inputIndex;
break;
Expand Down Expand Up @@ -3396,7 +3396,7 @@ IGraphTransformer::TStatus PgSetItemWrapper(const TExprNode::TPtr& input, TExprN
TVector<const TItemExprType*> newStructItems;
TColumnOrder newOrder;
for (ui32 i = 0; i < p->Child(2)->ChildrenSize(); ++i) {
auto pos = inputStructType->FindItem((*columnOrder)[i]);
auto pos = inputStructType->FindItemI((*columnOrder)[i]);
YQL_ENSURE(pos);
auto type = inputStructType->GetItems()[*pos]->GetItemType();
newOrder.push_back(TString(p->Child(2)->Child(i)->Content()));
Expand Down Expand Up @@ -4147,7 +4147,7 @@ IGraphTransformer::TStatus PgSetItemWrapper(const TExprNode::TPtr& input, TExprN
const auto type = data.Child(j)->Tail().GetTypeAnn()->Cast<TTypeExprType>()->
GetType()->Cast<TStructExprType>();
for (const auto& col : x.UsedExternalColumns) {
auto pos = type->FindItem(col);
auto pos = type->FindItemI(col);
YQL_ENSURE(pos);
items.push_back(type->GetItems()[*pos]);
}
Expand Down
Loading
Loading