Skip to content

Fix several bugs with collations. - #8051

Merged
alesapin merged 5 commits into
masterfrom
fix_collations_behaviour
Dec 8, 2019
Merged

alesapin merged 5 commits into
masterfrom
fix_collations_behaviour

Conversation

@alesapin

@alesapin alesapin commented Dec 5, 2019

Copy link
Copy Markdown
Member

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

alesapin commented Dec 5, 2019

Copy link
Copy Markdown
Member Author

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.

@alesapin

alesapin commented Dec 5, 2019

Copy link
Copy Markdown
Member Author

Comment thread dbms/src/Columns/Collator.cpp Resolved
Comment thread dbms/src/Columns/Collator.cpp Resolved
Comment thread dbms/src/Columns/Collator.cpp Resolved
Comment thread dbms/src/Columns/Collator.cpp Resolved
Comment thread dbms/src/Columns/Collator.cpp Resolved
Comment thread dbms/src/Columns/Collator.h Resolved
Comment thread dbms/src/Columns/Collator.cpp Resolved
Comment thread dbms/src/Columns/Collator.cpp Resolved
Comment thread dbms/src/Columns/Collator.cpp Outdated
return false;
}

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

Copy link
Copy Markdown
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.

if (status != U_ZERO_ERROR)
if (U_FAILURE(status))
{
ucol_close(collator);

Copy link
Copy Markdown
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.

Comment thread dbms/src/Interpreters/sortBlock.cpp Outdated


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

Copy link
Copy Markdown
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.

Comment thread dbms/src/Interpreters/sortBlock.cpp Outdated
{
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);

@KochetovNicolai KochetovNicolai Dec 6, 2019 •

Copy link
Copy Markdown
Member

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
Copy Markdown
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.

Comment thread dbms/src/Interpreters/sortBlock.cpp Outdated
{
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
Copy Markdown
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?

@KochetovNicolai KochetovNicolai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

.

Comment thread dbms/src/Columns/Collator.cpp Resolved
Comment thread dbms/src/Columns/Collator.cpp Resolved
Comment thread dbms/src/Columns/Collator.h Resolved
Comment thread dbms/src/Columns/Collator.h Resolved
Comment thread dbms/src/Interpreters/sortBlock.cpp Resolved
Comment thread dbms/src/Interpreters/sortBlock.cpp Resolved
Comment thread dbms/src/Interpreters/sortBlock.cpp Resolved

@KochetovNicolai KochetovNicolai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Almost ok.

@alesapin

alesapin commented Dec 8, 2019

Copy link
Copy Markdown
Member Author

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