Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLolthe1st committed Aug 15, 2024
1 parent f24776b commit 510663f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ydb/library/yql/core/type_ann/type_ann_pg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ bool ScanColumns(TExprNode::TPtr root, TInputs& inputs, const THashSet<TString>&
}
}

if (x.Order && x.Order->IsDuplicated(TString(node->Tail().Content()))) {
if (x.Order && x.Order->IsDuplicatedIgnoreCase(TString(node->Tail().Content()))) {
ctx.Expr.AddError(TIssue(ctx.Expr.GetPosition(node->Pos()),
TStringBuilder() << "Column reference is ambiguous: " << node->Tail().Content()));
isError = true;
Expand Down
7 changes: 7 additions & 0 deletions ydb/library/yql/core/ut/yql_column_order_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ Y_UNIT_TEST_SUITE(TYqlColumnOrder) {
UNIT_ASSERT_EQUAL(order.AddColumn("a_generated_2_generated_2"), "a_generated_2_generated_2_generated_2");
}

Y_UNIT_TEST(ColumnOrderCaseSensetive) {
TColumnOrder order;
UNIT_ASSERT_EQUAL(order.AddColumn("a"), "a");
UNIT_ASSERT_EQUAL(order.AddColumn("A"), "A");
UNIT_ASSERT_EQUAL(order.IsDuplicatedIgnoreCase("a"), true);
}

Y_UNIT_TEST(ColumnOrderGeneratedMatchOverVectorCtor) {
TColumnOrder order(TVector<TString>{"a", "a", "a_generated_2", "a_generated_2_generated_2"});
TVector<TColumnOrder::TOrderedItem> got(order.begin(), order.end());
Expand Down
2 changes: 1 addition & 1 deletion ydb/library/yql/core/yql_type_annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ TString TColumnOrder::AddColumn(const TString& name) {
return name;
}

bool TColumnOrder::IsDuplicated(const TString& name) const {
bool TColumnOrder::IsDuplicatedIgnoreCase(const TString& name) const {
auto it = UseCountLcase_.find(to_lower(name));
return it != UseCount_.end() && it->second > 1;
}
Expand Down
2 changes: 1 addition & 1 deletion ydb/library/yql/core/yql_type_annotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class TColumnOrder {
explicit TColumnOrder(const TVector<TString>& order);
TString AddColumn(const TString& name);

bool IsDuplicated(const TString& name) const;
bool IsDuplicatedIgnoreCase(const TString& name) const;

void Shrink(size_t remain);

Expand Down

0 comments on commit 510663f

Please sign in to comment.