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

Fix several bugs with collations. #8051

Merged
merged 5 commits into from
Dec 8, 2019
Merged

Conversation

alesapin
Copy link
Member

@alesapin alesapin commented Dec 5, 2019

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Bug Fix

Changelog entry (up to few sentences, required except for Non-significant/Documentation categories):
Restore support of all ICU locales, add the ability to apply collations for constant expressions and add language name to system.collations table.

@alesapin alesapin added the pr-bugfix Pull request with bugfix, not backported by default label Dec 5, 2019
@alesapin
Copy link
Member Author

alesapin commented Dec 5, 2019

Now we will throw an exception with some trash locales like en-US-u-va-posix, but some users may use them, because ICU fallback to some default locale in case of strange name.

}
return false;
}

Collator::Collator(const std::string & locale_) : locale(Poco::toLower(locale_))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we use toLowerInPlace, then can pass locale_ by value and maybe not copy string somewhere ...
it's not important also.

UErrorCode status = U_ZERO_ERROR;

collator = ucol_open(locale.c_str(), &status);
if (status != U_ZERO_ERROR)
if (U_FAILURE(status))
{
ucol_close(collator);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RAII would be better, but ok for now.

@@ -14,15 +15,21 @@ namespace ErrorCodes
}


static inline bool needCollation(const IColumn * column, const SortColumnDescription & description)
static inline const IColumn * needCollation(const IColumn * column, const SortColumnDescription & description)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now function's semantic has changes, but function name looks like it is still bool.

{
const ColumnString & column_string = typeid_cast<const ColumnString &>(*it->first);
const ColumnString & column_string = typeid_cast<const ColumnString &>(*column_string_ptr);
res = column_string.compareAtWithCollation(a, b, *it->first, *it->second.collator);
Copy link
Member

@KochetovNicolai KochetovNicolai Dec 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that if needCollation have returned nested column, it would have size=1. But we compare rows with numbers a and b.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll write a test.

{
const ColumnString & column_string = typeid_cast<const ColumnString &>(*column);
const ColumnString & column_string = typeid_cast<const ColumnString &>(*column_string_ptr);
column_string.getPermutationWithCollation(*description[0].collator, reverse, limit, perm);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same question. If column was const, then nested has size=1?

Copy link
Member

@KochetovNicolai KochetovNicolai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Member

@KochetovNicolai KochetovNicolai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost ok.

@alesapin
Copy link
Member Author

alesapin commented Dec 8, 2019

Performance tests flap.

@alesapin alesapin merged commit af7b8f9 into master Dec 8, 2019
KochetovNicolai pushed a commit that referenced this pull request Dec 17, 2019
Fix several bugs with collations.

(cherry picked from commit af7b8f9)
KochetovNicolai pushed a commit that referenced this pull request Dec 19, 2019
Fix several bugs with collations.

(cherry picked from commit af7b8f9)
KochetovNicolai pushed a commit that referenced this pull request Dec 20, 2019
Fix several bugs with collations.

(cherry picked from commit af7b8f9)
vitlibar pushed a commit that referenced this pull request Dec 26, 2019
Fix several bugs with collations.

(cherry picked from commit af7b8f9)
vitlibar pushed a commit that referenced this pull request Dec 27, 2019
Fix several bugs with collations.

(cherry picked from commit af7b8f9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix Pull request with bugfix, not backported by default
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants